Spaces:
Runtime error
Runtime error
| 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() | |
| def health(): | |
| return {"status": "ok"} | |
| 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") | |
| 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")) | |