-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
21 lines (18 loc) · 893 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from dotenv import load_dotenv
from Exceptions import MissingEnvironmentVariable
import os
load_dotenv() # load .env file into environment variables
basedir = os.path.abspath(os.path.dirname(__file__))
class Config():
APP_ENVIRONMENT = os.getenv("APP_ENVIRONMENT")
SECRET_KEY = os.environ.get('SECRET_KEY')
SESSION_PERMANENT = False
SESSION_TYPE = 'filesystem'
SQLALCHEMY_TRACK_MODIFICATIONS = False
PAGINATION_ITEMS_PER_PAGE = 3
if APP_ENVIRONMENT == "DEV":
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI', '')
elif APP_ENVIRONMENT == "PROD":
SQLALCHEMY_DATABASE_URI = \
os.environ.get('DATABASE_URI', '').replace('postgres://', 'postgresql://')
else: MissingEnvironmentVariable(f"APP_ENVIRONMENT environment variable should be either DEV or PROD. It is currently set to {APP_ENVIRONMENT} {type(APP_ENVIRONMENT)}")