Spaces:
Paused
Paused
| from contextlib import asynccontextmanager | |
| from pathlib import Path | |
| from fastapi import FastAPI | |
| from fastapi.staticfiles import StaticFiles | |
| from fastapi.responses import FileResponse | |
| from app.api.routes import router | |
| from app.core.config import settings | |
| from app.core.db import close_connection, get_connection | |
| STATIC_DIR = Path(__file__).parent.parent / "frontend" | |
| async def lifespan(app: FastAPI): | |
| get_connection() | |
| yield | |
| close_connection() | |
| app = FastAPI(title=settings.app_name, debug=settings.debug, lifespan=lifespan) | |
| app.include_router(router, prefix="/api") | |
| app.mount("/static", StaticFiles(directory=STATIC_DIR), name="static") | |
| async def health() -> dict[str, str]: | |
| return {"status": "ok"} | |
| async def index(): | |
| return FileResponse(STATIC_DIR / "index.html") | |