-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
44 lines (37 loc) · 1.33 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
from redis import StrictRedis
import logging
class Config(object):
DEBUG = True
SECRET_KEY ='ddsfggfgggrffsddddfrfrhhhlsdfklkfoejonnjowwehfwofkwmklfsflnfwo'
SQLALCHEMY_DATABASE_URI = 'mysql://root:[email protected]:3306/information'
SQLALCHEMY_TRACK_MODIFICATIONS = False
REDIS_HOST = "127.0.0.1"
REDIS_PORT = 6379
# 指定session使用什么来存储
SESSION_TYPE = 'redis'
# 指定session数据存储在后端的位置
SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
# 是否使用secret_key签名你的sessin
SESSION_USE_SIGNER = True
# 设置过期时间,要求'SESSION_PERMANENT', True。而默认就是31天
PERMANENT_SESSION_LIFETIME = 60 * 60 * 24 # 一天有效期
class DevlopmentConfig(Config):
"""开发环境"""
LEVEL_LOG = logging.DEBUG
class ProductionConfig(Config):
"""生产环境"""
DEBUG = False
SQLALCHEMY_DATABASE_URI = 'mysql://root:[email protected]:3306/information_pro'
# 生产环境日志等级
LEVEL_LOG = logging.ERROR
class UnittestConfig(Config):
"""测试环境"""
TESTING = True
SQLALCHEMY_DATABASE_URI = 'mysql://root:[email protected]:3306/information_case'
# 生产环境日志等级
LEVEL_LOG = logging.DEBUG
configs = {
'dev':DevlopmentConfig,
'pro':ProductionConfig,
'unit':UnittestConfig
}