Merge pull request #445: disable Flask debug mode by default

Default Flask debug mode to false while preserving explicit opt-in through FLASK_DEBUG.
This commit is contained in:
BaiFu 2026-07-22 19:40:39 +08:00 committed by GitHub
commit 231ec22bea
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 7 deletions

View File

@ -1,7 +1,4 @@
"""
配置管理
统一从项目根目录的 .env 文件加载配置
"""
"""\n配置管理\n统一从项目根目录的 .env 文件加载配置\n"""
import os
from dotenv import load_dotenv
@ -22,9 +19,9 @@ class Config:
# Flask配置
SECRET_KEY = os.environ.get('SECRET_KEY', 'mirofish-secret-key')
DEBUG = os.environ.get('FLASK_DEBUG', 'True').lower() == 'true'
DEBUG = os.environ.get('FLASK_DEBUG', 'False').lower() == 'true'
# JSON配置 - 禁用ASCII转义让中文直接显示(而不是 \uXXXX 格式)
# JSON配置 - 禁用ASCII转义让中文直接显示
JSON_AS_ASCII = False
# LLM配置统一使用OpenAI格式
@ -71,5 +68,7 @@ class Config:
errors.append("LLM_API_KEY 未配置")
if not cls.ZEP_API_KEY:
errors.append("ZEP_API_KEY 未配置")
if cls.DEBUG:
import warnings
warnings.warn("Flask DEBUG mode is enabled. Do not use in production.", RuntimeWarning)
return errors