Abhinav633 commited on
Commit
7721e79
Β·
verified Β·
1 Parent(s): c0da78a

Update backend/main.py

Browse files
Files changed (1) hide show
  1. backend/main.py +7 -19
backend/main.py CHANGED
@@ -22,29 +22,17 @@ app.add_middleware(
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", "")
 
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 / "static"
29
+
30
+ if _static_dir.exists():
31
+ app.mount("/assets", StaticFiles(directory=str(_static_dir / "assets")), name="assets")
32
 
33
  @app.get("/")
34
  async def serve_index():
35
+ return FileResponse(str(_static_dir / "index.html"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  # ── Config ────────────────────────────────────────────────────────────────────
37
  GROQ_MODEL = "llama-3.3-70b-versatile"
38
  GROQ_API_KEY = os.environ.get("GROQ_API_KEY", "")