Files
zjpb.net/config.py
Jowe 00397a63b8 fix: v2.1.0补充提交 - 配置完善和功能修复
修复内容:
- 完善tag_generator.py的generate_description方法
- 优化index_new.html首页图标CSS
- 更新templates/admin登录页面和后台模板
- 完善config.py配置
- 更新requirements.txt依赖列表
- 优化.gitignore规则

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-30 21:40:44 +08:00

65 lines
2.1 KiB
Python
Raw 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.
import os
from dotenv import load_dotenv
# 加载环境变量
load_dotenv()
class Config:
"""基础配置"""
# 密钥配置
SECRET_KEY = os.environ.get('SECRET_KEY') or 'dev-secret-key-change-in-production'
# 数据库配置
DB_HOST = os.environ.get('DB_HOST') or 'localhost'
DB_PORT = os.environ.get('DB_PORT') or '3306'
DB_USER = os.environ.get('DB_USER') or 'root'
DB_PASSWORD = os.environ.get('DB_PASSWORD') or ''
DB_NAME = os.environ.get('DB_NAME') or 'ai_nav'
SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}?charset=utf8mb4'
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ECHO = False
# 数据库连接池配置
SQLALCHEMY_ENGINE_OPTIONS = {
'pool_size': 10, # 连接池大小
'pool_recycle': 3600, # 连接回收时间(秒)
'pool_pre_ping': True, # 每次取连接前先ping确保连接有效
'pool_timeout': 30, # 连接池超时时间
'max_overflow': 20, # 超过pool_size后最多创建的连接数
'connect_args': {
'connect_timeout': 10, # 连接超时(秒)
'read_timeout': 30, # 读取超时(秒)
'write_timeout': 30, # 写入超时(秒)
}
}
# 分页配置
SITES_PER_PAGE = 20
# 上传文件配置
UPLOAD_FOLDER = 'static/uploads'
MAX_CONTENT_LENGTH = 5 * 1024 * 1024 # 5MB
ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'webp'}
# DeepSeek API配置
DEEPSEEK_API_KEY = os.environ.get('DEEPSEEK_API_KEY')
DEEPSEEK_BASE_URL = os.environ.get('DEEPSEEK_BASE_URL') or 'https://api.deepseek.com'
class DevelopmentConfig(Config):
"""开发环境配置"""
DEBUG = True
SQLALCHEMY_ECHO = True
class ProductionConfig(Config):
"""生产环境配置"""
DEBUG = False
SQLALCHEMY_ECHO = False
# 配置字典
config = {
'development': DevelopmentConfig,
'production': ProductionConfig,
'default': DevelopmentConfig
}