There was an error while loading. Please reload this page.
2 parents c795843 + 4cd5ed5 commit 9ad92c4Copy full SHA for 9ad92c4
1 file changed
src/main.py
@@ -1,17 +1,23 @@
1
+from contextlib import asynccontextmanager
2
+
3
from fastapi import FastAPI
4
from fastapi.middleware.cors import CORSMiddleware
5
6
from constants.settings import settings
7
import database.redis_db as redis
-from database.postgres_db import Base, dbEngine
8
from restful_ressources import import_resources
9
-Base.metadata.create_all(bind=dbEngine)
10
-redis.init()
11
+@asynccontextmanager
12
+async def lifespan(_app: FastAPI):
13
+ redis.init()
14
+ yield
15
16
17
_is_production = settings.APP_ENV == "production"
18
19
app = FastAPI(
20
+ lifespan=lifespan,
21
docs_url=None if _is_production else "/",
22
redoc_url=None if _is_production else "/redoc",
23
openapi_url=None if _is_production else "/openapi.json",
0 commit comments