from contextlib import asynccontextmanager import uvicorn from fastapi import FastAPI from app.common.error_handler import register_exception_handlers from app.core.config import settings @asynccontextmanager async def lifespan(app: FastAPI): yield def app_factory() -> FastAPI: app = FastAPI(title=settings.app_name, debug=settings.debug, lifespan=lifespan) register_exception_handlers(app) return app def main(): uvicorn.run(app_factory, factory=True, host=settings.host, port=settings.port) if __name__ == "__main__": main()