Phase 2 백엔드 마지막 task — FastAPI app · 11 endpoint · 10 route tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
34 lines
713 B
Python
34 lines
713 B
Python
"""saju-lab FastAPI app."""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from .config import CORS_ALLOW_ORIGINS
|
|
from .routers import saju, compat
|
|
from . import db as db_module
|
|
|
|
|
|
app = FastAPI(title="saju-lab")
|
|
|
|
_origins = [o.strip() for o in CORS_ALLOW_ORIGINS.split(",") if o.strip()]
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=_origins,
|
|
allow_credentials=False,
|
|
allow_methods=["GET", "POST", "PATCH", "DELETE", "OPTIONS"],
|
|
allow_headers=["Content-Type"],
|
|
)
|
|
|
|
|
|
@app.on_event("startup")
|
|
def _init():
|
|
db_module.init_db()
|
|
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
return {"ok": True}
|
|
|
|
|
|
app.include_router(saju.router)
|
|
app.include_router(compat.router)
|