config.py 1004 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import logging
  2. import redis
  3. class Config(object):
  4. """项目配置信息"""
  5. # 默认日志等级
  6. LOG_LEVEL = logging.DEBUG
  7. # 配置连接的数据库
  8. SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:[email protected]:3306/information"
  9. SQLALCHEMY_TRACK_MODIFICATIONS = True
  10. # 配置redis数据库
  11. REDIS_HOST = "127.0.0.1"
  12. REDIS_PORT = 6379
  13. # flask__session的配置信息
  14. SECRET_KEY = "1234567890"
  15. SESSION_TYPE = "redis" # 指定session保存到redis中
  16. SESSION_USE_SIGNER = True # 让cookie中的seesion_id 被加密签名处理
  17. SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
  18. PERMANENT_SESSION_LIFETIME = 86400 # session 的有效期,单位是秒
  19. class DebugConfig(Config):
  20. """测试环境下的配置"""
  21. DEBUG = True
  22. class ReleaseConfig(Config):
  23. """正式环境下的配置"""
  24. DEBUG = False
  25. LOG_LEVEL = logging.ERROR
  26. config_dict = {
  27. "debug": DebugConfig,
  28. "release": ReleaseConfig
  29. }