summaryrefslogtreecommitdiff
path: root/app/main.py
diff options
context:
space:
mode:
authorl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-27 13:45:09 +0300
committerl3wdfut4pwr <l3wdfut4pwr@gmail.com>2026-04-27 13:45:09 +0300
commit4848a9e9394b283022085a6305d00f94b11cd703 (patch)
treed7ba45885f110e8ded4af20bc98b9f88f75b1f4a /app/main.py
parentf1842be3bfabe7850d33662da2da377676144c48 (diff)
add username change and logout
Diffstat (limited to 'app/main.py')
-rw-r--r--app/main.py10
1 files changed, 9 insertions, 1 deletions
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: