import logging from contextlib import asynccontextmanager from fastapi import FastAPI, responses from gisaf.api import api from gisaf.geoapi import api as geoapi from gisaf.config import conf from gisaf.registry import registry from gisaf.redis_tools import setup_redis, setup_redis_cache, shutdown_redis from gisaf.live import setup_live logging.basicConfig(level=conf.gisaf.debugLevel) logger = logging.getLogger(__name__) @asynccontextmanager async def lifespan(app: FastAPI): await registry.make_registry() await setup_redis() await setup_redis_cache() await setup_live() yield await shutdown_redis() app = FastAPI( debug=False, title=conf.gisaf.title, version=conf.version, lifespan=lifespan, default_response_class=responses.ORJSONResponse, ) app.mount('/v2', api) app.mount('/gj', geoapi)