gisaf-backend/src/gisaf/application.py
phil 741050db89 Remove relative imports
Fix primary keys (optional)
Add baskets, importers, plugins, reactor
Add fake replacement fro graphql defs (to_migrate)
Add typing marker (py.typed)
2023-12-25 15:50:45 +05:30

35 lines
No EOL
846 B
Python

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)