fix(env): ensure the .env is loaded

This commit is contained in:
2025-10-26 14:55:43 +03:00
parent ce48859079
commit 2b7fecb248
5 changed files with 14 additions and 9 deletions
+2
View File
@@ -0,0 +1,2 @@
KEY= # Key for JWT token
POSTGRES_URL=postgresql://
+4 -1
View File
@@ -1,9 +1,12 @@
from sys import exit
from flask import Flask
from api.auth.loginapi import loginBP
from utils.loadDotEnv import initializeENV
from utils.PostgressConnect import PSQLConnect, PSQLCursor
state = initializeENV()
if not initializeENV():
exit(-1)
#conn = PSQLConnect()
#cur = PSQLCursor(conn)
+1 -1
View File
@@ -1,4 +1,4 @@
flask==3.1.2
python-dotenv
psycopg-binary
psycopg2-binary
pyjwt
+1 -1
View File
@@ -2,7 +2,7 @@ import psycopg2
import os
def PSQLConnect():
conn = psycopg2.connect(os.getenv('POSTDRESS_CONNECTION'))
conn = psycopg2.connect(os.getenv('POSTGRES_URL'))
return conn
def PSQLCursor(conn):
+6 -6
View File
@@ -2,14 +2,14 @@ import os
from dotenv import load_dotenv
from .createLogger import createLogger
DOTENV_PATH = '.env'
log = createLogger("ENV")
def initializeENV():
dotenv_path = '../.env'
if os.path.exists(dotenv_path):
load_dotenv(dotenv_path)
def initializeENV() -> bool:
if os.path.exists(DOTENV_PATH):
load_dotenv(DOTENV_PATH)
log.info('.env is loaded')
return 1
return True
else:
log.error('.env isn`t loaded')
return 0
return False