From 4848a9e9394b283022085a6305d00f94b11cd703 Mon Sep 17 00:00:00 2001 From: l3wdfut4pwr Date: Mon, 27 Apr 2026 13:45:09 +0300 Subject: add username change and logout --- app/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app/main.py') diff --git a/app/main.py b/app/main.py index f1c556a..49e7a1f 100644 --- a/app/main.py +++ b/app/main.py @@ -1,15 +1,20 @@ import time from contextlib import asynccontextmanager +from pathlib import Path +from dotenv import load_dotenv from fastapi import FastAPI from sqlalchemy import text from app.routes import router as api_router from app.utils.cors import setup_cors from app.utils.create_tables import init_db -from app.utils.db import engine +from app.utils.db import get_engine, init_db_engine from app.utils.logger_cfg import logger +load_dotenv(Path(__file__).resolve().parent.parent / ".env") +init_db_engine() + app_start_time = time.perf_counter() logger.debug("App start timestamp recorded") @@ -18,6 +23,8 @@ logger.debug("App start timestamp recorded") async def lifespan(app: FastAPI): logger.info("Application startup initiated") + engine = get_engine() + try: async with engine.begin() as conn: logger.debug("Executing test query: SELECT 1") @@ -46,6 +53,7 @@ async def lifespan(app: FastAPI): logger.info("Application shutdown initiated") try: + engine = get_engine() await engine.dispose() logger.info("Database engine disposed successfully") except Exception: -- cgit v1.3-3-g829e