Spaces:
Sleeping
Sleeping
Download app/main.py from otito254/epl-predictor-api: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/spaces/otito254/epl-predictor-api/resolve/main/app/main.py
- Command line
-
hf download hf://spaces/otito254/epl-predictor-api/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/otito254/epl-predictor-api/resolve/main/app/main.py
1.23 kB
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from app.api.v1.endpoints import matches, predict, pipeline | |
| from app.core.config import settings | |
| import logging | |
| # 1. Setup Logging | |
| logging.basicConfig(level=settings.LOG_LEVEL) | |
| logger = logging.getLogger(__name__) | |
| # 2. Create the ONE AND ONLY app instance | |
| app = FastAPI( | |
| title="EPL Match Outcome Predictor", | |
| description="Predicts EPL match outcomes using Random Forest + engineered features", | |
| version="1.0.0", | |
| ) | |
| # 3. Add Middleware | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=[ | |
| "http://localhost:3000", | |
| "https://epl-predictor-4drj.vercel.app/", # Your actual Vercel domain | |
| ], | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # 4. Define Routes | |
| def root(): | |
| return {"status": "ok", "message": "EPL Predictor API is running"} | |
| def health_check(): | |
| return {"status": "ok", "version": "1.0.0"} | |
| # 5. Include Routers | |
| app.include_router(matches.router, prefix="/api/v1", tags=["Matches"]) | |
| app.include_router(predict.router, prefix="/api/v1", tags=["Predictions"]) | |
| app.include_router(pipeline.router, prefix="/api/v1", tags=["Pipeline"]) |