-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.py
More file actions
103 lines (85 loc) · 2.97 KB
/
config.py
File metadata and controls
103 lines (85 loc) · 2.97 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
# coding: utf-8
# config
# project base path
import os
basedir = os.path.abspath(os.path.dirname(__file__))
"""
common configuration
-- SECRET_KEY: secret key
-- SQLALCHEMY_COMMIT_ON_TEARDOWN: True
-- SQLALCHEMY_RECORD_QUERIES:
-- Can be used to explicitly disable or enable query recording.
Query recording automatically happens in debug or testing mode.
-- SQLALCHEMY_TRACK_MODIFICATIONS:
-- If set to True, Flask-SQLAlchemy will track modifications of
objects and emit signals.
The default is None, which enables tracking but issues a warning that
it will be disabled by default in the future.
This requires extra memory and should be disabled if not needed.
more configuration keys please see:
-- http://flask-sqlalchemy.pocoo.org/2.1/config/#configuration-keys
"""
class Config:
"""common configuration"""
SECRET_KEY = os.environ.get("SECRET_KEY") or "hard to guess string"
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_TRACK_MODIFICATIONS = True
"""mail configuration"""
MAIL_SERVER = 'smtp.qq.com'
MAIL_PORT = 25
MAIL_USE_TLS = True
MAIL_DEBUG = True
MAIL_USERNAME = os.getenv('AUTH_MAIL_USERNAME')
MAIL_PASSWORD = os.getenv('AUTH_MAIL_PASSWORD')
MAIL_DEFAULT_SENDER = MAIL_USERNAME
AUTH_MAIL_SUBJECT_PREFIX = '[木犀团队]'
REDIS_BROKER_HOSTNAME = os.getenv('REDIS_BROKER_HOSTNAME')
REDIS_BACKEND_HOSTNAME = os.getenv('REDIS_BACKEND_HOSTNAME')
"""celery configuration"""
CELERY_BROKER_URL = 'redis://{}:6385/1'.format(os.environ.get('REDIS_BROKER_HOSTNAME'))
CELERY_RESULT_BACKEND = 'redis://{}:6386/1'.format(os.environ.get('REDIS_BACKEND_HOSTNAME'))
@staticmethod
def init_app(app):
pass
"""
development configuration
-- DEBUG: debug mode
-- SQLALCHEMY_DATABASE_URI:
-- The database URI that should be used for the connection.
more connection URI format:
-- Postgres:
-- postgresql://scott:tiger@localhost/mydatabase
-- MySQL:
-- mysql://scott:tiger@localhost/mydatabase
-- Oracle:
-- oracle://scott:tiger@127.0.0.1:1521/sidname
"""
class DevelopmentConfig(Config):
"""development configuration"""
DEBUG = True
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(basedir, "data-dev.sqlite")
"""
testing configuration
-- TESTING: True
-- WTF_CSRF_ENABLED:
-- in testing environment, we don't need CSRF enabled
"""
class TestingConfig(Config):
"""testing configuration"""
TESTING = True
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(basedir, "data-test.sqlite")
WTF_CSRF_ENABLED = False
# production configuration
class ProductionConfig(Config):
"""production configuration"""
SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI" )
@classmethod
def init_app(cls, app):
Config.init_app(app)
config = {
"develop": DevelopmentConfig,
"testing": TestingConfig,
"production": ProductionConfig,
"default": DevelopmentConfig
}