forked from ncthuc/flask-api-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
45 lines (33 loc) · 1.27 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
import os
# import dotenv
basedir = os.path.abspath(os.path.dirname(__file__))
# dotenv.load_dotenv(os.path.join(basedir, '../../.env'))
ETC_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), 'etc'))
class Config:
SECRET_KEY = os.getenv('SECRET_KEY', 'my_precious_secret_key')
LOGGING_CONFIG_FILE = os.path.join(ETC_DIR, 'logging.ini')
DEBUG = False
BABEL_TRANSLATION_DIRECTORIES = '../translations'
LANGUAGES = ['en', 'vi']
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
class DevelopmentConfig(Config):
DEBUG = True
# SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'flask_boilerplate_main.db')
SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL')
SQLALCHEMY_TRACK_MODIFICATIONS = False
class TestingConfig(Config):
DEBUG = True
TESTING = True
# SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'flask_boilerplate_test.db')
SQLALCHEMY_DATABASE_URI = os.getenv('TEST_DATABASE_URL')
PRESERVE_CONTEXT_ON_EXCEPTION = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
class ProductionConfig(Config):
DEBUG = False
SQLALCHEMY_DATABASE_URI = os.getenv('DATABASE_URL')
config_by_name = dict(
dev=DevelopmentConfig,
test=TestingConfig,
prod=ProductionConfig
)
key = Config.SECRET_KEY