Spaces:
Runtime error
Runtime error
Download app/main.py from akashmx77/image_tools: direct link, hf CLI and curl.
- Browser
- Download file 776 Bytes
-
https://huggingface.co/spaces/akashmx77/image_tools/resolve/main/app/main.py
- Command line
-
hf download hf://spaces/akashmx77/image_tools/app/main.py
-
curl -L -o main.py https://huggingface.co/spaces/akashmx77/image_tools/resolve/main/app/main.py
776 Bytes
| # app/main.py | |
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from app.api import bg_removal, enhancer | |
| from app.core.config import settings | |
| import os | |
| os.environ["NUMBA_DISABLE_CACHE"] = "1" | |
| app = FastAPI(title="Image Tools API") | |
| # Use centralized CORS settings | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=settings.ALLOWED_ORIGINS, | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| # Ensure static directory exists at startup | |
| async def startup_event(): | |
| os.makedirs("app/static", exist_ok=True) | |
| # Register routers | |
| app.include_router(bg_removal.router, prefix="/bg", tags=["Background Removal"]) | |
| app.include_router(enhancer.router, prefix="/enhance", tags=["Enhancer"]) | |