Spaces:
Sleeping
Sleeping
update main.py debug user/admin change
Browse files
main.py
CHANGED
|
@@ -578,7 +578,8 @@ async def health_check():
|
|
| 578 |
return {"status": "healthy", "model_loaded": mlp_pipeline is not None, "database": os.path.exists(db_path)}
|
| 579 |
|
| 580 |
# ================ STATIC FILES (SPA SUPPORT) ================
|
| 581 |
-
|
|
|
|
| 582 |
# 1. Mount the assets folder (JS/CSS built by Vite/React)
|
| 583 |
if os.path.exists("static/assets"):
|
| 584 |
app.mount("/assets", StaticFiles(directory="static/assets"), name="assets")
|
|
@@ -591,8 +592,11 @@ async def serve_react_app(full_path: str, request: Request):
|
|
| 591 |
if full_path.startswith("api") or full_path.startswith("ws"):
|
| 592 |
raise HTTPException(status_code=404, detail="Not Found")
|
| 593 |
|
| 594 |
-
|
| 595 |
-
if os.path.
|
| 596 |
-
return FileResponse(
|
|
|
|
|
|
|
|
|
|
| 597 |
else:
|
| 598 |
-
return {"message": "React app not found. Please run 'npm run build'
|
|
|
|
| 578 |
return {"status": "healthy", "model_loaded": mlp_pipeline is not None, "database": os.path.exists(db_path)}
|
| 579 |
|
| 580 |
# ================ STATIC FILES (SPA SUPPORT) ================
|
| 581 |
+
FRONTEND_DIR = "dist" if os.path.exists("dist/index.html") else "static"
|
| 582 |
+
assets_path = os.path.join(FRONTEND_DIR, "assets")
|
| 583 |
# 1. Mount the assets folder (JS/CSS built by Vite/React)
|
| 584 |
if os.path.exists("static/assets"):
|
| 585 |
app.mount("/assets", StaticFiles(directory="static/assets"), name="assets")
|
|
|
|
| 592 |
if full_path.startswith("api") or full_path.startswith("ws"):
|
| 593 |
raise HTTPException(status_code=404, detail="Not Found")
|
| 594 |
|
| 595 |
+
file_path = os.path.join(FRONTEND_DIR, full_path)
|
| 596 |
+
if os.path.isfile(file_path):
|
| 597 |
+
return FileResponse(file_path)
|
| 598 |
+
index_path = os.path.join(FRONTEND_DIR, "index.html")
|
| 599 |
+
if os.path.exists(index_path):
|
| 600 |
+
return FileResponse(index_path)
|
| 601 |
else:
|
| 602 |
+
return {"message": f"React app not found. Please run 'npm run build'."}
|