Spaces:
Sleeping
Sleeping
File size: 810 Bytes
20f4f84 44c0d0c 20f4f84 44c0d0c 20f4f84 44c0d0c 20f4f84 44c0d0c 20f4f84 44c0d0c 20f4f84 44c0d0c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import os
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from routes import router
from model_loader import load_model
app = FastAPI()
# CORS for browser extension access
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # You can restrict this later
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Mount all routes
app.include_router(router)
@app.on_event("startup")
def on_startup():
print("🚀 Starting Hugging Face Space API")
load_model()
if os.getenv("SUPABASE_URL") and os.getenv("SUPABASE_KEY"):
print("🔗 Supabase logging is enabled")
else:
print("⚠️ Supabase logging disabled (env not set)")
@app.on_event("shutdown")
def on_shutdown():
print("🧹 Shutdown complete")
|