Spaces:
Sleeping
Sleeping
| 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) | |
| 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)") | |
| def on_shutdown(): | |
| print("π§Ή Shutdown complete") | |