Spaces:
Paused
Paused
Update backend/main.py
Browse files- backend/main.py +21 -7
backend/main.py
CHANGED
|
@@ -380,15 +380,29 @@ async def docker_images():
|
|
| 380 |
return {"images": images}
|
| 381 |
|
| 382 |
|
| 383 |
-
# ββ Health ββββββββββββββββββββββ
|
| 384 |
|
| 385 |
-
@app.get("/")
|
| 386 |
-
async def
|
| 387 |
return {"status": "ok", "name": "TreyOS", "version": "1.0.0"}
|
| 388 |
|
| 389 |
|
| 390 |
-
# ββ Serve Frontend βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 391 |
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
return {"images": images}
|
| 381 |
|
| 382 |
|
| 383 |
+
# ββ Health Check (Moved to avoid colliding with Root UI) ββββββββββββββββββββββ
|
| 384 |
|
| 385 |
+
@app.get("/health")
|
| 386 |
+
async def health_check():
|
| 387 |
return {"status": "ok", "name": "TreyOS", "version": "1.0.0"}
|
| 388 |
|
| 389 |
|
| 390 |
+
# ββ Serve Frontend UI βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 391 |
|
| 392 |
+
from fastapi.responses import HTMLResponse
|
| 393 |
+
|
| 394 |
+
@app.get("/", response_class=HTMLResponse)
|
| 395 |
+
async def serve_root_ui():
|
| 396 |
+
"""Serves the main structural HTML interface directly at the app root."""
|
| 397 |
+
# Looks for TreyOS-connected.html in the root workspace directory (/trey)
|
| 398 |
+
root_html_path = Path(__file__).parent.parent / "TreyOS-connected.html"
|
| 399 |
+
if root_html_path.exists():
|
| 400 |
+
return root_html_path.read_text(encoding="utf-8")
|
| 401 |
+
else:
|
| 402 |
+
raise HTTPException(status_code=404, detail="TreyOS-connected.html not found in root context.")
|
| 403 |
+
|
| 404 |
+
|
| 405 |
+
# Correctly mount the real frontend directory containing treyos-client.js
|
| 406 |
+
real_frontend_path = Path(__file__).parent.parent / "frontend"
|
| 407 |
+
if real_frontend_path.exists():
|
| 408 |
+
app.mount("/frontend", StaticFiles(directory=str(real_frontend_path)), name="frontend")
|