Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI | |
| from fastapi.middleware.cors import CORSMiddleware | |
| from app.api.v1.router import api_router | |
| from app.core.config import settings | |
| from app.db.init_db import init_db | |
| def create_app() -> FastAPI: | |
| app = FastAPI(title=settings.PROJECT_NAME) | |
| app.add_middleware( | |
| CORSMiddleware, | |
| allow_origins=["*"], # tighten for production | |
| allow_credentials=True, | |
| allow_methods=["*"], | |
| allow_headers=["*"], | |
| ) | |
| app.include_router(api_router, prefix=settings.API_V1_STR) | |
| def on_startup(): | |
| init_db() | |
| return app | |
| app = create_app() | |