-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
56 lines (41 loc) · 1.37 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
import logging
from redis import StrictRedis
class Config(object):
"""项目的配置"""
SECRET_KEY = "iECgbYWReMNxkRprrzMo5KAQYnb2UeZ3bwvReTSt+VSESW0OB8zbglT+6rEcDW9X"
# 为数据库添加配置
SQLALCHEMY_DATABASE_URI = "mysql://root:[email protected]:3306/information1"
SQLALCHEMY_TRACK_MODIFICATIONS = False
# 在请求结束时候,如果指定此配置为 True ,那么 SQLAlchemy 会自动执行一次 db.session.commit()操作
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
# Redis的配置
REDIS_HOST = "127.0.0.1"
REDIS_PORT = 6379
# Session保存配置
SESSION_TYPE = "redis"
# 开启session签名
SESSION_USE_SIGNER = True
# 指定 Session 保存的 redis
SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
# 设置需要过期
SESSION_PERMANENT = False
# 设置过期时间
PERMANENT_SESSION_LIFETIME = 86400 * 2
# 设置日志等级
LOG_LEVEL = logging.DEBUG
class DevelopmentConfig(Config):
"""开发环境下的配置"""
DEBUG = True
class ProductionConfig(Config):
"""生产环境下的配置"""
DEBUG = False
LOG_LEVEL = logging.WARNING
class TestingConfig(Config):
"""单元测试环境下的配置"""
DEBUG = True
TESTING = True
config = {
"development": DevelopmentConfig,
"production": ProductionConfig,
"testing": TestingConfig
}