Spaces:
Sleeping

otito254's picture
main api cors
cb49361
Raw History Blame Contribute Delete
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
@app.get("/")
def root():
return {"status": "ok", "message": "EPL Predictor API is running"}
@app.get("/health")
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"])