from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from scalar_fastapi import get_scalar_api_reference
from Douyin_TikTok_Download_API.app.api import router
web_app_tikhub = FastAPI(title="Modal Tikhub API",
                         version="1.0.0",
                         summary="Modal Tikhub API, 包含抖音Web API",
                         )

web_app_tikhub.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

@web_app_tikhub.get("/scalar", include_in_schema=False)
async def scalar():
    return get_scalar_api_reference(openapi_url='/openapi.json', title="Modal worker web endpoint")

web_app_tikhub.include_router(router.router)