mirror of
https://git.victorphan.net/basketballcantho/ten-project.git
synced 2026-08-05 11:53:10 +07:00
32 lines
977 B
Python
32 lines
977 B
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from .routers import admin, annotations, auth, backup, pdfs, ws
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
# Tables are managed by Alembic migrations.
|
|
# Run: alembic upgrade head (done by docker-compose entrypoint)
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="LMS API", lifespan=lifespan)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:3000", "http://localhost:3001"],
|
|
allow_credentials=True, # required for cookies
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(auth.router, prefix="/api")
|
|
app.include_router(admin.router, prefix="/api")
|
|
app.include_router(backup.router, prefix="/api")
|
|
app.include_router(pdfs.router, prefix="/api")
|
|
app.include_router(annotations.router, prefix="/api")
|
|
app.include_router(ws.router) # WebSocket — no /api prefix (ws:// path)
|