-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
60 lines (48 loc) · 1.72 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
import os
import platform
basedir = os.path.abspath(os.path.dirname(__file__))
class Config:
SECRET_KEY = "it's really hard to guess"
# Commit database changes when tearing down
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_TRACK_MODIFICATIONS = True
MAIL_SERVER = 'smtp.gmail.com'
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
FLASKY_MAIL_SUBJECT_PREFIX = '[HUSTRunner]'
FLASKY_MAIL_SENDER = 'HUSTRunner Admin <HUSTRunner@example.com>'
FLASK_ADMIN = 'polyval@mail.com'
@staticmethod
def init__app(app):
pass
class DevelopmentConfig(Config):
SQLALCHEMY_DATABASE_URI = \
'mysql+pymysql://root:password@localhost/hustrunner'
@classmethod
def init_app(cls, app):
Config.init__app(app)
import logging
from logging.handlers import RotatingFileHandler
file_handler = RotatingFileHandler('hustrunner.log', maxBytes=1024*1024*100, backupCount=20)
file_handler.setLevel(logging.ERROR)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter)
app.logger.addHandler(file_handler)
class TestingConfig(Config):
TESTING = True
DEBUG = True
if platform.system() == 'Windows':
SQLALCHEMY_DATABASE_URI = \
'sqlite:///' + os.path.join(basedir, 'data-test.sqlite')
else:
SQLALCHEMY_DATABASE_URI = \
'sqlite:////' + os.path.join(basedir, 'data-test.sqlite')
@classmethod
def init_app(cls, app):
Config.init__app(app)
config = {
'development': DevelopmentConfig,
'testing': TestingConfig,
}