Abhinav633 commited on
Commit
a8a1f04
Β·
verified Β·
1 Parent(s): 4fae14c

Update backend/main.py

Browse files
Files changed (1) hide show
  1. 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
- _static_dir = pathlib.Path(__file__).parent.parent / "backend" / "static"
29
- if _static_dir.exists():
30
- app.mount("/assets", StaticFiles(directory=str(_static_dir / "assets")), name="assets")
31
-
32
- @app.get("/")
33
- async def serve_index():
34
- return FileResponse(str(_static_dir / "index.html"))
35
- else:
36
- @app.get("/")
37
- async def serve_fallback():
38
- return {"status": "running", "message": "static dir not found at: " + str(_static_dir)}
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", "")