Spaces:
Sleeping
Sleeping
Download api/main.py from ApyHTML19/Triple-R-Checker: direct link, hf CLI and curl.
- Browser
- Download file 968 Bytes
-
https://huggingface.co/spaces/ApyHTML19/Triple-R-Checker/resolve/main/api/main.py
- Command line
-
hf download hf://spaces/ApyHTML19/Triple-R-Checker/api/main.py
-
curl -L -o main.py https://huggingface.co/spaces/ApyHTML19/Triple-R-Checker/resolve/main/api/main.py
968 Bytes
| 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")) | |