fix(env): ensure the .env is loaded
This commit is contained in:
@@ -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
@@ -1,4 +1,4 @@
|
||||
flask==3.1.2
|
||||
python-dotenv
|
||||
psycopg-binary
|
||||
psycopg2-binary
|
||||
pyjwt
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user