2025-08-17 21:25:55 +08:00
|
|
|
|
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'
|
2026-04-02 17:39:09 +08:00
|
|
|
|
|
|
|
|
|
|
# 开发环境API配置(如果未设置,使用示例值并给出警告)
|
|
|
|
|
|
if not self.LLM_API_KEY:
|
|
|
|
|
|
self.LLM_API_KEY = 'sk-dev-example-api-key'
|
|
|
|
|
|
import warnings
|
|
|
|
|
|
warnings.warn("LLM_API_KEY not set, using development example key")
|
|
|
|
|
|
|
|
|
|
|
|
if not self.WX_APPID:
|
|
|
|
|
|
self.WX_APPID = 'wx-dev-example-appid'
|
|
|
|
|
|
|
|
|
|
|
|
if not self.WX_SECRET:
|
|
|
|
|
|
self.WX_SECRET = 'wx-dev-example-secret'
|
|
|
|
|
|
|
|
|
|
|
|
# 开发环境CORS配置(如果没有设置,使用开发默认值)
|
|
|
|
|
|
if not self.CORS_ORIGINS or self.CORS_ORIGINS == ['']:
|
|
|
|
|
|
self.CORS_ORIGINS = ['http://localhost:3000', 'http://127.0.0.1:3000', '*']
|
2025-08-17 21:25:55 +08:00
|
|
|
|
|
|
|
|
|
|
# 开发环境日志配置
|
|
|
|
|
|
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('开发环境启动')
|