Coverage for src/kwai/app.py: 0%
18 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that creates a FastAPI application for the API and Frontend."""
3from contextlib import asynccontextmanager
5from fastapi import FastAPI
6from loguru import logger
8from kwai.api.app import create_api
9from kwai.frontend.app import create_frontend
12APP_NAME = "kwai"
15@asynccontextmanager
16async def lifespan(app: FastAPI):
17 """Log the start/stop of the application."""
18 logger.info(f"{APP_NAME} is starting")
19 yield
20 logger.warning(f"{APP_NAME} has ended!")
23def create_app() -> FastAPI:
24 """Create the FastAPI application for API and frontend."""
25 main_app = FastAPI(title=APP_NAME, lifespan=lifespan)
27 api_app = create_api()
28 main_app.mount("/api", api_app)
30 frontend_app = create_frontend()
31 main_app.mount("/", frontend_app)
33 return main_app