forked from YKPS-FooBar/swim4love
-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
48 lines (33 loc) · 1.14 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
"""Configurations for the Flask app.
Note that additional configurations are also set in run.py
"""
import os
class Config:
'''Common configurations.'''
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
SQLALCHEMY_DATABASE_URI = 'sqlite:///swim4love.db'
THREADS_PER_PAGE = 2
CSRF_ENABLED = True
CORS_HEADERS = 'Content-Type'
class DevelopmentConfig(Config):
'''Development configurations.'''
ENV = 'development'
TESTING = True
DEBUG = True
JSONIFY_PRETTYPRINT_REGULAR = True
SQLALCHEMY_ECHO = True
SQLALCHEMY_TRACK_MODIFICATIONS = True
class ProductionConfig(Config):
'''Production configurations.'''
ENV = 'production'
TESTING = False
DEBUG = False
JSONIFY_PRETTYPRINT_REGULAR = False
SQLALCHEMY_ECHO = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
if not os.path.isfile('instance/secrets.py'):
print('No secret key file (instance/secrets.py) detected. Auto-generating...')
os.makedirs('instance', exist_ok=True)
with open('instance/secrets.py', 'w') as file:
file.write('SECRET_KEY = {!r}\n'.format(os.urandom(24).hex()))
app_config = ProductionConfig