from fastapi import FastAPI from fastapi.responses import FileResponse from fastapi.staticfiles import StaticFiles from api.inference import predict_claim from api.schema import ClaimRequest, PredictionResponse import os app = FastAPI() @app.get("/health") def health(): return {"status": "ok"} @app.post("/predict") def predict_claim_endpoint(claim_request: ClaimRequest): prediction = predict_claim(claim_request.claim) return PredictionResponse(prediction=prediction) STATIC_DIR = "frontend/dist/frontend/browser" if os.path.exists(STATIC_DIR): app.mount("/assets", StaticFiles(directory=STATIC_DIR), name="assets") @app.get("/{full_path:path}") async def serve_spa(full_path: str): file_path = os.path.join(STATIC_DIR, full_path) if full_path and os.path.exists(file_path) and os.path.isfile(file_path): return FileResponse(file_path) return FileResponse(os.path.join(STATIC_DIR, "index.html"))