28 lines
607 B
Python
28 lines
607 B
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.api_v1 import api_router
|
|
from app.core.config import get_settings
|
|
from app.db.init_db import init_db
|
|
|
|
settings = get_settings()
|
|
|
|
app = FastAPI(title=settings.PROJECT_NAME)
|
|
|
|
if settings.BACKEND_CORS_ORIGINS:
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.BACKEND_CORS_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
|
|
@app.on_event("startup")
|
|
def on_startup():
|
|
init_db()
|
|
|
|
|
|
app.include_router(api_router, prefix="/api/v1")
|