-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.py
executable file
·92 lines (77 loc) · 2.67 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import os
basedir = os.path.abspath(os.path.dirname(__file__))
APP_ROOT = os.path.dirname(os.path.abspath(__file__))
class Config(object):
"""
Global configuration from which other configs inherit
:cvar THREADS_PER_PAGE: 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.
:cvar CSRF_SESSION_KEY Use a secure, unique and absolutely secret key for signing the data.
:cvar SQLALCHEMY_DATABASE_URI Define the database - we are working with SQLite for this example
"""
SECRET_KEY = os.environ.get('SECRET_KEY') or 'hadithi'
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
SQLALCHEMY_TRACK_MODIFICATIONS = True
SQLALCHEMY_DATABASE_URI = os.environ["DATABASE_URL"]
SECURITY_PASSWORD_SALT = os.environ.get("SECURITY_PASSWORD_SALT") or 'my_precious_two'
ROOT_DIR = APP_ROOT
WTF_CSRF_ENABLED = True
CSRF_ENABLED = True
CSRF_SESSION_KEY = os.environ.get("CSRF_SESSION_KEY")
THREADS_PER_PAGE = 2
DATABASE_CONNECT_OPTIONS = {}
# mail settings
MAIL_SERVER = 'smtp.googlemail.com'
MAIL_PORT = 465
MAIL_USE_TLS = False
MAIL_USE_SSL = True
# gmail authentication
MAIL_USERNAME = os.environ['APP_MAIL_USERNAME']
MAIL_PASSWORD = os.environ['APP_MAIL_PASSWORD']
MAIL_DEFAULT_SENDER = os.environ["MAIL_DEFAULT_SENDER"]
# credentials for external service accounts
OAUTH_CREDENTIALS = {
"facebook": {
"id": os.environ["FACEBOOK_ID"],
"secret": os.environ["FACEBOOK_SECRET"]
},
"google": {
"id": os.environ["GOOGLE_ID"],
"secret": os.environ["GOOGLE_SECRET"]
}
}
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
"""
Development configuration
"""
DEBUG = True
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
# SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(basedir, 'app.db')
class TestingConfig(Config):
"""
Testing configurations
"""
DEBUG = True
TESTING = True
SQLALCHEMY_DATABASE_URI = 'sqlite:///:memory:'
WTF_CSRF_ENABLED = False
CSRF_ENABLED = False
PRESERVE_CONTEXT_ON_EXCEPTION = False
class ProductionConfig(Config):
"""
Production configuration
"""
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL')
ADMINS = [os.environ.get("ADMIN_EMAIL_1")]
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}