-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
65 lines (47 loc) · 1.36 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
from distutils.debug import DEBUG
import os
from dotenv import load_dotenv
# load the .env
basedir = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(basedir, '.env'))
# API key and env variables
CALORIES_NINJA_API_KEY = os.getenv('CALORIES_NINJA_API_KEY')
FLASK_ENV = os.getenv('FLASK_ENV')
# SECTION - config classes
class Config(object):
'''
Config parent class
'''
SECRET_KEY = os.getenv('SECRET_KEY')
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ECHO = False
class ProductionConfig(Config):
'''
Config for production
'''
DEBUG = False
# db config
uri = os.getenv("DATABASE_URL")
if uri and uri.startswith("postgres://"):
uri = uri.replace("postgres://", "postgresql://", 1)
SQLALCHEMY_DATABASE_URI = uri
class DevelopmentConfig(Config):
'''
Config for developement (inherited from super class Config)
'''
DEBUG = True
# Flask debugtoolbar config
DEBUG_TB_INTERCEPT_REDIRECTS = False
# db config
SQLALCHEMY_DATABASE_URI = os.getenv("DEV_DB_URL")
class TestConfig(Config):
'''
Config to run unit and integration test
'''
# Enable testing mode. Exceptions are propagated rather than handled by the the app’s error handlers
DEBUG = False
TESTING = True
# disable @login_required
LOGIN_DISABLED = True
SQLALCHEMY_DATABASE_URI = os.getenv('TEST_DB_URL')
WTF_CSRF_ENABLED = False