first commit
This commit is contained in:
commit
34ea15a54d
246 changed files with 18660 additions and 0 deletions
43
backend/app/main.py
Normal file
43
backend/app/main.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
from app.api.router import api_router
|
||||
from app.core.config import get_settings
|
||||
from app.core.errors import register_exception_handlers
|
||||
|
||||
|
||||
def create_app() -> FastAPI:
|
||||
settings = get_settings()
|
||||
app = FastAPI(
|
||||
title="Desi Clans API",
|
||||
version="0.2.0",
|
||||
debug=settings.environment.lower() == "development",
|
||||
)
|
||||
|
||||
register_exception_handlers(app)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.cors_origin_list,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
if settings.storage_backend.lower() == "local":
|
||||
upload_path = Path(settings.upload_dir)
|
||||
upload_path.mkdir(parents=True, exist_ok=True)
|
||||
app.mount("/media", StaticFiles(directory=str(upload_path)), name="media")
|
||||
|
||||
if settings.environment.lower() == "production":
|
||||
app.openapi_url = None
|
||||
|
||||
app.include_router(api_router, prefix="/api")
|
||||
|
||||
return app
|
||||
|
||||
|
||||
app = create_app()
|
||||
Loading…
Add table
Add a link
Reference in a new issue