import asyncio from contextlib import asynccontextmanager import uvicorn from fastapi import FastAPI from internal_loop import internal_loop from api import testAPI from influx_related import init_influx @asynccontextmanager async def startup(fast_api: FastAPI): # Startup logic print("startup") influxdb_client = init_influx(fast_api) asyncio.create_task(internal_loop(influxdb_client)) yield # Shutdown logic app = FastAPI(lifespan=startup) app.include_router( testAPI.router, prefix='/api', tags=['testApi'], ) # Press the green button in the gutter to run the script. if __name__ == '__main__': uvicorn.run( "main:app", host='0.0.0.0', port=8082, log_level='debug', )