-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
config.py
75 lines (58 loc) · 2.22 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from dotenv import load_dotenv
load_dotenv()
import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config(object):
ENV = ''
DEBUG = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_DATABASE_URI = os.environ.get('db_url') # Store it in the hosting config
COMPANY_NAME = 'Your company name' # Change to your company name
JWT_SECRET_KEY = os.environ.get('JWT_SECRET_KEY')
SECRET_KEY = os.environ.get('SECRET_KEY')
MAIL_SERVER = os.environ.get('MAIL_SERVER')
MAIL_PORT = os.environ.get('MAIL_PORT')
MAIL_USE_SSL = True if os.getenv('MAIL_USE_SSL') == 'True' else False
MAIL_USE_TLS = True if os.getenv('MAIL_USE_TLS') == 'True' else False
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_DEFAULT_SENDER = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
ADMIN_EMAIL = os.environ.get('ADMIN_EMAIL')
#AWS
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_KEY = os.environ.get('AWS_SECRET_KEY')
AWS_BUCKET_NAME = os.environ.get('AWS_BUCKET_NAME') # Create additional variables for other buckets
class ProductionConfig(Config):
ENV = 'prod'
DEBUG = False
class DevelopmentConfig(Config):
ENV = 'dev'
DEVELOPMENT = True
DEBUG = True
class TestingConfig(Config):
ENV = 'test'
TESTING = True
config = {
'dev': DevelopmentConfig,
'test': TestingConfig,
'prod': ProductionConfig,
'default' : DevelopmentConfig
}
class ConfigHelper:
# Allows setting config from argument, or from "env" environment variable (see Activate.bat)
@staticmethod
def __check_config_name(env_name):
return env_name is not None and env_name != '' and env_name in config is not None
@staticmethod
def set_config(args):
if (args is not None and len(args) > 1):
# Check argument
if ConfigHelper.__check_config_name(args[1]):
return config[args[1]]
# Check os env var
env = os.environ.get('env')
if ConfigHelper.__check_config_name(env):
if config.get(env):
return config.get(env)
# Nothing worked, return default config
return config['default']