Spaces:
Sleeping
Sleeping
404 error2
Browse files- app/main.py +14 -16
app/main.py
CHANGED
|
@@ -3,39 +3,37 @@ from fastapi.middleware.cors import CORSMiddleware
|
|
| 3 |
from app.api.v1.endpoints import matches, predict, pipeline
|
| 4 |
from app.core.config import settings
|
| 5 |
import logging
|
| 6 |
-
from fastapi import FastAPI
|
| 7 |
-
|
| 8 |
-
app = FastAPI()
|
| 9 |
-
|
| 10 |
-
@app.get("/")
|
| 11 |
-
def root():
|
| 12 |
-
return {"status": "ok", "message": "EPL Predictor API is running"}
|
| 13 |
|
|
|
|
| 14 |
logging.basicConfig(level=settings.LOG_LEVEL)
|
| 15 |
logger = logging.getLogger(__name__)
|
| 16 |
|
|
|
|
| 17 |
app = FastAPI(
|
| 18 |
title="EPL Match Outcome Predictor",
|
| 19 |
description="Predicts EPL match outcomes using Random Forest + engineered features",
|
| 20 |
version="1.0.0",
|
| 21 |
)
|
| 22 |
|
|
|
|
| 23 |
app.add_middleware(
|
| 24 |
CORSMiddleware,
|
| 25 |
-
allow_origins=[
|
| 26 |
-
"http://localhost:3000",
|
| 27 |
-
"https://your-vercel-app.vercel.app", # ← replace with real URL at deploy time
|
| 28 |
-
],
|
| 29 |
allow_credentials=True,
|
| 30 |
allow_methods=["*"],
|
| 31 |
allow_headers=["*"],
|
| 32 |
)
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
app.
|
| 36 |
-
|
| 37 |
-
|
| 38 |
|
| 39 |
@app.get("/health")
|
| 40 |
def health_check():
|
| 41 |
-
return {"status": "ok", "version": "1.0.0"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from app.api.v1.endpoints import matches, predict, pipeline
|
| 4 |
from app.core.config import settings
|
| 5 |
import logging
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
# 1. Setup Logging
|
| 8 |
logging.basicConfig(level=settings.LOG_LEVEL)
|
| 9 |
logger = logging.getLogger(__name__)
|
| 10 |
|
| 11 |
+
# 2. Create the ONE AND ONLY app instance
|
| 12 |
app = FastAPI(
|
| 13 |
title="EPL Match Outcome Predictor",
|
| 14 |
description="Predicts EPL match outcomes using Random Forest + engineered features",
|
| 15 |
version="1.0.0",
|
| 16 |
)
|
| 17 |
|
| 18 |
+
# 3. Add Middleware
|
| 19 |
app.add_middleware(
|
| 20 |
CORSMiddleware,
|
| 21 |
+
allow_origins=["*"], # Or your specific URLs
|
|
|
|
|
|
|
|
|
|
| 22 |
allow_credentials=True,
|
| 23 |
allow_methods=["*"],
|
| 24 |
allow_headers=["*"],
|
| 25 |
)
|
| 26 |
|
| 27 |
+
# 4. Define Routes
|
| 28 |
+
@app.get("/")
|
| 29 |
+
def root():
|
| 30 |
+
return {"status": "ok", "message": "EPL Predictor API is running"}
|
| 31 |
|
| 32 |
@app.get("/health")
|
| 33 |
def health_check():
|
| 34 |
+
return {"status": "ok", "version": "1.0.0"}
|
| 35 |
+
|
| 36 |
+
# 5. Include Routers
|
| 37 |
+
app.include_router(matches.router, prefix="/api/v1", tags=["Matches"])
|
| 38 |
+
app.include_router(predict.router, prefix="/api/v1", tags=["Predictions"])
|
| 39 |
+
app.include_router(pipeline.router, prefix="/api/v1", tags=["Pipeline"])
|