Files
aitsc/config/development.py

54 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from .base import Config
class DevelopmentConfig(Config):
"""
开发环境配置
"""
DEBUG = True
TESTING = False
# 开发环境数据库配置如果未设置环境变量使用SQLite
def __init__(self):
super().__init__()
if not self.SQLALCHEMY_DATABASE_URI:
self.SQLALCHEMY_DATABASE_URI = 'sqlite:///dev.db'
# 开发环境日志配置
LOG_LEVEL = 'DEBUG'
LOG_FILE = 'logs/dev.log'
# 开发环境缓存配置
CACHE_TYPE = 'simple'
CACHE_DEFAULT_TIMEOUT = 60 # 开发环境缓存时间较短
# 开发环境安全配置
WTF_CSRF_ENABLED = False # 开发环境关闭CSRF保护
# 开发环境会话配置
SESSION_LIFETIME_HOURS = 24
# 开发环境文件上传配置
MAX_CONTENT_LENGTH = 32 * 1024 * 1024 # 32MB
UPLOAD_FOLDER = 'uploads/dev'
# 开发环境跨域配置
CORS_ORIGINS = ['http://localhost:3000', 'http://127.0.0.1:3000', '*']
@staticmethod
def init_app(app):
Config.init_app(app)
# 开发环境特定初始化
import logging
app.logger.setLevel(logging.DEBUG)
# 开发环境控制台输出
console_handler = logging.StreamHandler()
console_handler.setLevel(logging.DEBUG)
console_handler.setFormatter(logging.Formatter(
'%(asctime)s %(levelname)s: %(message)s'
))
app.logger.addHandler(console_handler)
app.logger.info('开发环境启动')