-
Notifications
You must be signed in to change notification settings - Fork 27
/
config.py
71 lines (51 loc) · 1.95 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
import os
# Define the application directory
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
class Config(object):
DATABASE_CONNECT_OPTIONS = {}
# Turn off Flask-SQLAlchemy event system
SQLALCHEMY_TRACK_MODIFICATIONS = True
# Application threads. A common general assumption is
# using 2 per available processor cores - to handle
# incoming requests using one and performing background
# operations using the other.
THREADS_PER_PAGE = 2
# Enable protection agains *Cross-site Request Forgery (CSRF)*
WTF_CSRF_ENABLED = True
# Use a secure, unique and absolutely secret key for
# signing the data.
CSRF_SESSION_KEY = os.getenv('CSRF_SESSION_KEY')
# Secret key for signing cookies
if os.environ.get('SECRET_KEY'):
SECRET_KEY = os.environ.get('SECRET_KEY')
else:
SECRET_KEY = 'SECRET'
# for email with sendgrid
SENDGRID_API_KEY = os.environ.get('SENDGRID_API_KEY')
SENDGRID_DEFAULT_FROM = '[email protected]'
@staticmethod
def init_app(app):
pass
class ProductionConfig(Config):
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(BASE_DIR, 'app.db')
class DevelopmentConfig(Config):
"""Statement for enabling the development environment"""
# Define the database - we are working with
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(BASE_DIR, 'dev.db')
DEBUG = True
class APIConfig(Config):
"""Statement for enabling the api environment"""
# Define the database - we are working with
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(BASE_DIR, 'dev.db')
WTF_CSRF_ENABLED = False
class TestingConfig(Config):
TESTING = True
WTF_CSRF_ENABLED = False
PRESERVE_CONTEXT_ON_EXCEPTION = False
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(BASE_DIR, 'test.db')
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'production': ProductionConfig,
'api': APIConfig,
}