diff --git a/fastapi/app/database.py b/fastapi/app/database.py index 9487ab2..87da73e 100644 --- a/fastapi/app/database.py +++ b/fastapi/app/database.py @@ -14,8 +14,8 @@ def create_async_uri(uri): return uri.replace('postgresql', 'postgresql+asyncpg') -engine = create_engine(Config.API_DB_URI, echo=True, poolclass=NullPool) -async_engine = create_async_engine(create_async_uri(Config.API_DB_URI), echo=True, poolclass=NullPool) +engine = create_engine(Config.API_DB_URI, echo=False, poolclass=NullPool) +async_engine = create_async_engine(create_async_uri(Config.API_DB_URI), echo=False, poolclass=NullPool) async_session = sessionmaker(async_engine, expire_on_commit=False, class_=AsyncSession) Session = sessionmaker(autocommit=False, autoflush=False, bind=engine) diff --git a/fastapi/app/main.py b/fastapi/app/main.py index e076bf4..80da2cd 100644 --- a/fastapi/app/main.py +++ b/fastapi/app/main.py @@ -849,9 +849,8 @@ async def get_all_routes(): @app.on_event("startup") async def startup_event(): try: - redis_pool = await aioredis.from_url(Config.REDIS_URL) - redis = RedisBackend(redis_pool) - FastAPICache.init(backend=redis, prefix="fastapi-cache") + crud.redis = await aioredis.from_url(Config.REDIS_URL) + FastAPICache.init(backend=crud.redis, prefix="fastapi-cache") uvicorn_access_logger = logging.getLogger("uvicorn.access") uvicorn_error_logger = logging.getLogger("uvicorn.error") logger = logging.getLogger("uvicorn.app") @@ -878,7 +877,6 @@ async def startup_event(): except: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stderr) - app.add_middleware( CORSMiddleware, allow_origins=["*"],