Spaces:
Sleeping
Sleeping
Update backend/main.py
Browse files- backend/main.py +21 -13
backend/main.py
CHANGED
|
@@ -22,21 +22,29 @@ app.add_middleware(
|
|
| 22 |
)
|
| 23 |
# ββ Static files + SPA βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 24 |
from fastapi.staticfiles import StaticFiles
|
| 25 |
-
from fastapi.responses import FileResponse
|
| 26 |
import pathlib
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
# ββ Config ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 41 |
GROQ_MODEL = "llama-3.3-70b-versatile"
|
| 42 |
GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")
|
|
|
|
| 22 |
)
|
| 23 |
# ββ Static files + SPA βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 24 |
from fastapi.staticfiles import StaticFiles
|
| 25 |
+
from fastapi.responses import FileResponse, PlainTextResponse
|
| 26 |
import pathlib
|
| 27 |
+
import os
|
| 28 |
|
| 29 |
+
@app.get("/")
|
| 30 |
+
async def serve_index():
|
| 31 |
+
# Try multiple possible paths
|
| 32 |
+
candidates = [
|
| 33 |
+
pathlib.Path(__file__).parent / "static" / "index.html",
|
| 34 |
+
pathlib.Path("/app/backend/static/index.html"),
|
| 35 |
+
pathlib.Path("/app/static/index.html"),
|
| 36 |
+
]
|
| 37 |
+
for path in candidates:
|
| 38 |
+
if path.exists():
|
| 39 |
+
return FileResponse(str(path))
|
| 40 |
+
|
| 41 |
+
# None found - show debug info
|
| 42 |
+
debug = f"Tried:\n"
|
| 43 |
+
for p in candidates:
|
| 44 |
+
debug += f" {p} -> exists={p.exists()}\n"
|
| 45 |
+
debug += f"\n/app contents: {os.listdir('/app')}\n"
|
| 46 |
+
debug += f"/app/backend contents: {os.listdir('/app/backend')}\n"
|
| 47 |
+
return PlainTextResponse(debug, status_code=200)
|
| 48 |
# ββ Config ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 49 |
GROQ_MODEL = "llama-3.3-70b-versatile"
|
| 50 |
GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")
|