from fastapi import FastAPI from fastapi.responses import HTMLResponse from fastapi.middleware.cors import CORSMiddleware import joblib import pandas as pd app = FastAPI() app.add_middleware( CORSMiddleware, allow_origins=["*"], # Allows all origins allow_credentials=True, allow_methods=["*"], # Allows all methods allow_headers=["*"], # Allows all headers ) # Load models once at startup future_spend_model = joblib.load("future_spend_7d.pkl") spike_model = joblib.load("spike_probability.pkl") acc_model = joblib.load("acceleration.pkl") FEATURES = joblib.load("model_features.pkl") @app.get("/", response_class=HTMLResponse) def root(): return """
The API is active and ready to accept requests.