-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconfig.py
More file actions
127 lines (98 loc) · 2.99 KB
/
Copy pathconfig.py
File metadata and controls
127 lines (98 loc) · 2.99 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
"""
Specify main configs here
Other configs are specified in module's global.py in like
configs = {
"development": {
"CONFIG_VAR": "DEVVALUE"
},
"production": {
"CONFIG_VAR": "PRODVALUE"
},
"testing": {
"CONFIG_VAR": "TESTVALUE"
}
}
"""
import os
base_path = os.path.dirname(os.path.abspath(__file__))
class BaseConfig:
"""Parent configuration class."""
DEBUG = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
BASE_DIR = base_path
STATIC = os.path.join(base_path, "static")
UPLOADED_PATH_IMAGE = os.path.join(STATIC, "uploads", "images")
UPLOADED_PATH_THUMB = os.path.join(STATIC, "uploads", "thumbs")
class ProductionConfig(BaseConfig):
"""Configurations for production"""
# built in flask configs
ENV = "production"
SECRET_KEY = os.environ.get("SECRET_KEY")
# control email confirmation for user registration
EMAIL_CONFIRMATION_DISABLED = False
# flask-mailman configs
MAIL_SERVER = "smtp.googlemail.com"
MAIL_PORT = 465
MAIL_USE_TLS = False
MAIL_USE_SSL = True
MAIL_USERNAME = os.environ.get("MAIL_USERNAME")
MAIL_PASSWORD = os.environ.get("MAIL_PASSWORD")
MAIL_DEFAULT_SENDER = os.environ.get("MAIL_DEFAULT_SENDER")
# database configs
SQLALCHEMY_DATABASE_URI = (
os.environ.get("SQLALCHEMY_DATABASE_URI") or "sqlite:///shopyo.db"
)
class DevelopmentConfig(BaseConfig):
"""Configurations for development"""
# built in flask configs
ENV = "development"
DEBUG = True
LOGIN_DISABLED = False
SECRET_KEY = "secret"
# control email confirmation for user registration
EMAIL_CONFIRMATION_DISABLED = False
# flask-mailman configs
MAIL_SERVER = "localhost"
MAIL_PORT = 1025
MAIL_USE_TLS = False
MAIL_USE_SSL = False
MAIL_USERNAME = ""
MAIL_PASSWORD = ""
MAIL_DEFAULT_SENDER = "ma@mail.com"
# database configs
SQLALCHEMY_DATABASE_URI = (
os.environ.get("SQLALCHEMY_DATABASE_URI") or "sqlite:///shopyo.db"
)
# unknown configs
PASSWORD_SALT = "some pasword salt"
class TestingConfig(BaseConfig):
"""Configurations for testsing"""
# built in flask configs
ENV = "testing"
TESTING = True
DEBUG = True
SERVER_NAME = "localhost.com"
SECRET_KEY = "secret"
PREFERRED_URL_SCHEME = "http"
# flask WTF configs
WTF_CSRF_ENABLED = False
# control email confirmation for user registration
EMAIL_CONFIRMATION_DISABLED = False
# flask-mailman configs
MAIL_BACKEND = "console"
MAIL_USERNAME = "shopyofrom@test.com"
MAIL_PASSWORD = "pass"
MAIL_DEFAULT_SENDER = "shopyofrom@test.com"
# flask sqlalchemy configs
SQLALCHEMY_DATABASE_URI = "sqlite:///testing.db"
# flask bycrpt configs
BCRYPT_LOG_ROUNDS = 4
# unknown configs
PASSWORD_SALT = "some pasword salt"
LIVESERVER_PORT = 8943
LIVESERVER_TIMEOUT = 10
app_config = {
"development": DevelopmentConfig,
"production": ProductionConfig,
"testing": TestingConfig,
}