init
This commit is contained in:
+40
-17
@@ -40,17 +40,17 @@ from fastapi.templating import Jinja2Templates
|
||||
import asyncio
|
||||
|
||||
from api.routes import router
|
||||
from api.auth_routes import router as auth_router
|
||||
from api.inventory_routes import router as inventory_router
|
||||
from utils.logger import setup_logging
|
||||
from database.init_db import init_database
|
||||
|
||||
# 设置日志
|
||||
setup_logging()
|
||||
|
||||
# 创建FastAPI应用
|
||||
app = FastAPI(
|
||||
title="模具几何分析服务",
|
||||
description="基于PythonOCC的STP文件几何分析和模具设计建议服务",
|
||||
version="3.0.0"
|
||||
title="Gemold - 模具制造管理系统",
|
||||
description="模具制造行业综合管理平台,包含模具分析、进销存管理等功能",
|
||||
version="4.0.0"
|
||||
)
|
||||
|
||||
# 启动时初始化数据库和RustFS
|
||||
@@ -96,7 +96,8 @@ import os
|
||||
static_dir = os.path.join(os.getcwd(), "static")
|
||||
app.mount("/static", StaticFiles(directory=static_dir), name="static")
|
||||
|
||||
# 注册路由
|
||||
app.include_router(auth_router)
|
||||
app.include_router(inventory_router)
|
||||
app.include_router(router)
|
||||
|
||||
|
||||
@@ -106,25 +107,47 @@ async def health():
|
||||
from database.database import db_manager
|
||||
return {
|
||||
"status": "healthy",
|
||||
"service": "mold-geometry-analysis",
|
||||
"service": "gemold",
|
||||
"version": "4.0.0",
|
||||
"database_connected": db_manager.is_connected
|
||||
}
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
from fastapi.responses import FileResponse
|
||||
return FileResponse(os.path.join(os.getcwd(), "static", "index.html"))
|
||||
|
||||
|
||||
@app.get("/moldinsight")
|
||||
async def moldinsight():
|
||||
from fastapi.responses import FileResponse
|
||||
return FileResponse(os.path.join(os.getcwd(), "static", "index.html"))
|
||||
|
||||
|
||||
@app.get("/inventory")
|
||||
async def inventory():
|
||||
from fastapi.responses import FileResponse
|
||||
return FileResponse(os.path.join(os.getcwd(), "static", "index.html"))
|
||||
|
||||
|
||||
@app.get("/users")
|
||||
async def users():
|
||||
from fastapi.responses import FileResponse
|
||||
return FileResponse(os.path.join(os.getcwd(), "static", "index.html"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
# 从配置文件获取端口配置
|
||||
from config.settings import settings
|
||||
|
||||
print("启动模具几何分析服务 v3.0...")
|
||||
print(f"访问 http://localhost:{settings.PORT} 使用网页界面")
|
||||
print("新增功能:")
|
||||
print(" - STP文件解析为JSON数据")
|
||||
print(" - 数据存储到PostgreSQL数据库")
|
||||
print(" - 自动生成3D可视化HTML页面")
|
||||
print(" - 源文件、JSON数据、HTML文件统一管理")
|
||||
print(f"调试接口: http://localhost:{settings.PORT}/debug/tasks")
|
||||
print("启动 Gemold 模具制造管理系统 v4.0...")
|
||||
print(f"访问 http://localhost:{settings.PORT}")
|
||||
print("功能模块:")
|
||||
print(" - 首页仪表盘")
|
||||
print(" - 用户管理")
|
||||
print(" - MoldInsight 模具分析")
|
||||
print(" - 进销存管理")
|
||||
|
||||
uvicorn.run(
|
||||
"main:app",
|
||||
|
||||
Reference in New Issue
Block a user