2021-11-23 13:00:03 +00:00
|
|
|
import os
|
2022-06-11 13:26:50 +01:00
|
|
|
from pathlib import Path
|
2022-06-20 12:27:32 +01:00
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv('../.env')
|
2022-06-17 01:10:11 +01:00
|
|
|
|
2021-11-23 13:00:03 +00:00
|
|
|
class Config(object):
|
2022-08-20 12:01:08 +01:00
|
|
|
"""Basic App Configuration"""
|
2022-06-11 02:39:47 +01:00
|
|
|
APP_HOST = '0.0.0.0'
|
2022-06-22 11:56:36 +01:00
|
|
|
DATA = './data/'
|
2021-11-23 13:00:03 +00:00
|
|
|
DEBUG = False
|
|
|
|
TESTING = False
|
|
|
|
SECRET_KEY = os.getenv('SECRET_KEY')
|
2022-06-16 13:22:06 +01:00
|
|
|
SERVER_NAME = os.getenv('SERVER_NAME')
|
2021-11-23 13:00:03 +00:00
|
|
|
SESSION_COOKIE_SECURE = True
|
|
|
|
|
2022-08-20 12:01:08 +01:00
|
|
|
"""Email Engine Configuration"""
|
2022-06-11 11:29:15 +01:00
|
|
|
MAIL_SERVER = os.getenv('MAIL_SERVER')
|
2022-06-22 11:45:37 +01:00
|
|
|
MAIL_PORT = int(os.getenv('MAIL_PORT') or 25)
|
2021-11-23 13:00:03 +00:00
|
|
|
MAIL_USE_TLS = False
|
|
|
|
MAIL_USE_SSL = False
|
|
|
|
MAIL_DEBUG = False
|
2022-06-11 11:29:15 +01:00
|
|
|
MAIL_USERNAME = os.getenv('MAIL_USERNAME')
|
|
|
|
MAIL_PASSWORD = os.getenv('MAIL_PASSWORD')
|
|
|
|
MAIL_DEFAULT_SENDER = os.getenv('MAIL_DEFAULT_SENDER')
|
2022-06-22 11:45:37 +01:00
|
|
|
MAIL_MAX_EMAILS = int(os.getenv('MAIL_MAX_EMAILS') or 25)
|
2021-11-23 13:00:03 +00:00
|
|
|
MAIL_SUPPRESS_SEND = False
|
2022-06-22 11:45:37 +01:00
|
|
|
MAIL_ASCII_ATTACHMENTS = bool(os.getenv('MAIL_ASCII_ATTACHMENTS') or True)
|
2021-11-23 13:00:03 +00:00
|
|
|
|
2022-08-20 12:01:08 +01:00
|
|
|
"""Database Driver Configuration"""
|
|
|
|
DATABASE_TYPE = os.getenv('DATABASE_TYPE') or 'SQLite'
|
|
|
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
|
|
|
|
|
|
|
if DATABASE_TYPE.lower() == 'mysql' and os.getenv('MYSQL_DATABASE') and os.getenv('MYSQL_USER') and os.getenv('MYSQL_PASSWORD'):
|
|
|
|
DATABASE_HOST = os.getenv('DATABASE_HOST') or 'localhost'
|
|
|
|
DATABASE_PORT = int(os.getenv('DATABASE_PORT') or 3306)
|
|
|
|
MYSQL_DATABASE = os.getenv('MYSQL_DATABASE')
|
|
|
|
MYSQL_USER = os.getenv('MYSQL_USER')
|
|
|
|
MYSQL_PASSWORD = os.getenv('MYSQL_PASSWORD')
|
|
|
|
SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{MYSQL_USER}:{MYSQL_PASSWORD}@{DATABASE_HOST}:{DATABASE_PORT}/{MYSQL_DATABASE}'
|
2022-09-13 11:00:07 +01:00
|
|
|
else: SQLALCHEMY_DATABASE_URI = f'sqlite:///{Path(os.path.abspath(f"{DATA}/db.sqlite"))}'
|
2022-08-20 12:01:08 +01:00
|
|
|
|
2022-06-19 11:17:00 +01:00
|
|
|
class Production(Config):
|
2021-11-23 13:00:03 +00:00
|
|
|
pass
|
|
|
|
|
2022-06-19 11:17:00 +01:00
|
|
|
class Development(Config):
|
2022-06-11 02:39:47 +01:00
|
|
|
APP_HOST = '127.0.0.1'
|
2021-11-23 13:00:03 +00:00
|
|
|
DEBUG = True
|
2022-06-20 11:26:44 +01:00
|
|
|
SERVER_NAME = '127.0.0.1:5000'
|
2021-11-23 13:00:03 +00:00
|
|
|
SESSION_COOKIE_SECURE = False
|
2021-12-05 03:49:31 +00:00
|
|
|
MAIL_SERVER = 'localhost'
|
2021-11-23 13:00:03 +00:00
|
|
|
MAIL_DEBUG = True
|
|
|
|
MAIL_SUPPRESS_SEND = False
|
|
|
|
|
2022-06-19 11:17:00 +01:00
|
|
|
class Testing(Development):
|
2021-11-23 13:00:03 +00:00
|
|
|
TESTING = True
|
|
|
|
SESSION_COOKIE_SECURE = False
|
2022-06-11 11:29:15 +01:00
|
|
|
MAIL_SERVER = os.getenv('MAIL_SERVER')
|
2021-11-23 13:00:03 +00:00
|
|
|
MAIL_DEBUG = True
|
2022-06-11 02:39:47 +01:00
|
|
|
MAIL_SUPPRESS_SEND = False
|