Spaces:
Paused
Paused
File size: 1,611 Bytes
ec17af3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | from contextlib import asynccontextmanager
import logging
import sys
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.config import settings
from app.db import Base, engine
from app.middleware.logging import StructuredLoggingMiddleware
from app.middleware.security_headers import SecurityHeadersMiddleware
from app.routes import (
auth,
coaching,
curriculum,
dashboard,
health,
jobs,
news,
sessions,
settings as settings_routes,
setup,
)
from app.schema_upgrades import apply_startup_schema_upgrades
logging.basicConfig(
level=logging.INFO,
format="%(message)s",
handlers=[logging.StreamHandler(sys.stdout)],
)
logging.getLogger("uvicorn.access").setLevel(logging.WARNING)
@asynccontextmanager
async def lifespan(_app: FastAPI):
Base.metadata.create_all(bind=engine)
apply_startup_schema_upgrades()
yield
app = FastAPI(title="Speech-Machine Tech Presenter Coach API", lifespan=lifespan)
app.add_middleware(SecurityHeadersMiddleware)
app.add_middleware(StructuredLoggingMiddleware)
app.add_middleware(
CORSMiddleware,
allow_origins=settings.cors_origin_list,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(setup.router)
app.include_router(auth.router)
app.include_router(dashboard.router)
app.include_router(curriculum.router)
app.include_router(news.router)
app.include_router(coaching.router)
app.include_router(sessions.router)
app.include_router(settings_routes.router)
app.include_router(jobs.router)
app.include_router(health.router)
|