Spaces:
Running
Running
File size: 939 Bytes
01923e1 | 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 31 32 33 34 35 36 37 38 39 | from pathlib import Path
from fastapi import APIRouter, FastAPI, HTTPException
from fastapi.staticfiles import StaticFiles
from .content import EXAMPLE, PROJECT
from .models import Example, Project
app = FastAPI(title="MedCaseAgent Project", version="0.1.0")
api = APIRouter(prefix="/api")
@api.get("/health")
def health() -> dict[str, str]:
return {"status": "ok"}
@api.get("/project", response_model=Project)
def project() -> Project:
return PROJECT
@api.get("/example", response_model=Example)
def example() -> Example:
return EXAMPLE
app.include_router(api)
@app.get("/api/{path:path}", include_in_schema=False)
def missing_api(path: str) -> None:
raise HTTPException(status_code=404, detail="API endpoint not found")
frontend_dist = Path(__file__).resolve().parents[2] / "frontend" / "dist"
if frontend_dist.is_dir():
app.mount("/", StaticFiles(directory=frontend_dist, html=True), name="frontend")
|