Refactor config, logging, and startup structure

Introduced pkg modules for environment config, logging, and startup initialization. Replaced direct config and logging setup in main.py with modularized functions. Updated database and migration modules to use environment variables and improved DEBUG handling. Removed tool.py and migrated password utilities to pkg. Cleaned up legacy comments and unused code in models and routes.
This commit is contained in:
2025-10-03 15:00:45 +08:00
parent 815e709339
commit c1c36c606f
16 changed files with 214 additions and 185 deletions

6
app.py
View File

@@ -33,18 +33,18 @@ app.include_router(object.Router)
@app.get("/")
def read_root():
if not os.path.exists("dist/index.html"):
raise HTTPException(status_code=404, detail="Frontend not built. Please build the frontend first.")
raise HTTPException(status_code=404)
return FileResponse("dist/index.html")
# 回退路由
@app.get("/{path:path}")
async def serve_spa(request: Request, path: str):
if not os.path.exists("dist/index.html"):
raise HTTPException(status_code=404, detail="Frontend not built. Please build the frontend first.")
raise HTTPException(status_code=404)
# 排除API路由
if path.startswith("api/"):
raise HTTPException(status_code=404, detail="Not Found")
raise HTTPException(status_code=404)
# 检查是否是静态资源请求
if path.startswith("assets/") and os.path.exists(f"dist/{path}"):