You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

25 lines
600 B

import uvicorn
from fastapi import FastAPI, HTTPException
from fastapi.responses import ORJSONResponse
from core.settings import settings
from api import router
from core.models import db_helper
from contextlib import asynccontextmanager
@asynccontextmanager
async def lifespan(app: FastAPI):
#start up
yield
#shutdown
await db_helper.dispose()
main_app = FastAPI(
lifespan=lifespan,
default_response_class=ORJSONResponse
)
#api/hello
main_app.include_router(router)
if __name__ == "__main__":
uvicorn.run(main_app, host=settings.run.host, port=settings.run.port)