File size: 1,130 Bytes
81c4c9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
app.py
HF Spaces entry point β€” serves both the FastAPI backend and the frontend UI.
HF Spaces runs this file directly with: python app.py
"""

import uvicorn
from fastapi.staticfiles import StaticFiles
from fastapi.responses import FileResponse
from pathlib import Path

from api.main import app

# ── Serve frontend ────────────────────────────────────────────────────────────
# Mount the frontend folder so index.html is served at "/"

FRONTEND_DIR = Path(__file__).parent / "frontend"

@app.get("/", include_in_schema=False)
async def serve_frontend():
    return FileResponse(FRONTEND_DIR / "index.html")

# ── Run ───────────────────────────────────────────────────────────────────────
if __name__ == "__main__":
    uvicorn.run(
        "app:app",
        host="0.0.0.0",
        port=7860,      # HF Spaces default port
        reload=False,
    )