This repository has been archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathconfig.py
54 lines (47 loc) · 1.91 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
import logging
from redis import StrictRedis
APP_ENV = "testing"
class BaseConfig:
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
#是否开启跟踪
SQLALCHEMY_TRACK_MODIFICATIONS = True
SECRET_KEY = "hello"
'''
根据业务和场景添加其他相关配置
'''
#配置Redis数据库
REDIS_HOST = '127.0.0.1'
REDIS_PORT = 6379
REDIS_DB = 1
# 配置session数据存储到redis数据库
SESSION_TYPE = 'redis'
# 指定存储session数据的redis的位置
SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT,db=REDIS_DB)
# 开启session数据的签名,意思是让session数据不以明文形式存储
SESSION_USE_SIGNER = True
# 設置session的会话的超时时长 :一天,全局指定
PERMANENT_SESSION_LIFETIME = 3600 * 24
#QQ邮箱配置
MAIL_DEBUG = True # 开启debug,便于调试看信息
MAIL_SUPPRESS_SEND = False # 发送邮件,为True则不发送
MAIL_SERVER = 'smtp.qq.com' # 邮箱服务器
MAIL_PORT = 465 # 端口
MAIL_USE_SSL = True # 重要,qq邮箱需要使用SSL
MAIL_USE_TLS = False # 不需要使用TLS
MAIL_USERNAME = '[email protected]' # 填邮箱
MAIL_PASSWORD = 'ttvnyuzklhqbjeg' # 填授权码
FLASK_MAIL_SENDER = '皮皮虾!我们走!<[email protected]>' #邮件发送方
FLASK_MAIL_SUBJECT_PREFIX = '[皮皮虾!我们走]' #邮件标题
#MAIL_DEFAULT_SENDER = '[email protected]' # 填邮箱,默认发送者
class TestingConfig(BaseConfig):
DEBUG = True
LOGGING_LEVEL = logging.DEBUG
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://Bean:[email protected]:3306/test"
class DevelopmentConfig(BaseConfig):
DEBUG = False
LOGGING_LEVEL = logging.WARNING
SQLALCHEMY_DATABASE_URI = "mysql+pymysql://Bean:[email protected]:3306/test"
config = {
"testing": TestingConfig,
"devolopment": DevelopmentConfig,
}