55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
from scalar_fastapi import get_scalar_api_reference
|
|
|
|
from app.admin_manager import init_admin
|
|
from app.core.common import lifespan
|
|
from app.database.session import engine
|
|
from app.home.api.routers.v1.home import router as home_router
|
|
from app.lyric.api.routers.v1.lyric import router as lyric_router
|
|
from app.song.api.routers.v1.song import router as song_router
|
|
from app.video.api.routers.v1.video import router as video_router
|
|
from app.utils.cors import CustomCORSMiddleware
|
|
from config import prj_settings
|
|
|
|
app = FastAPI(
|
|
title=prj_settings.PROJECT_NAME,
|
|
version=prj_settings.VERSION,
|
|
description=prj_settings.DESCRIPTION,
|
|
lifespan=lifespan,
|
|
docs_url=None, # 기본 Swagger UI 비활성화
|
|
redoc_url=None, # 기본 ReDoc 비활성화
|
|
)
|
|
|
|
init_admin(app, engine)
|
|
|
|
custom_cors_middleware = CustomCORSMiddleware(app)
|
|
custom_cors_middleware.configure_cors()
|
|
|
|
app.mount("/static", StaticFiles(directory="static"), name="static")
|
|
app.mount("/media", StaticFiles(directory="media"), name="media")
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
allow_credentials=True,
|
|
max_age=-1,
|
|
)
|
|
|
|
|
|
@app.get("/docs", include_in_schema=False)
|
|
def get_scalar_docs():
|
|
return get_scalar_api_reference(
|
|
openapi_url=app.openapi_url,
|
|
title="Scalar API",
|
|
)
|
|
|
|
|
|
app.include_router(home_router)
|
|
app.include_router(lyric_router) # Lyric API 라우터 추가
|
|
app.include_router(song_router) # Song API 라우터 추가
|
|
app.include_router(video_router) # Video API 라우터 추가
|