You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# 导入os模块, 用于操作系统相关功能( 如环境变量、路径操作等)
import os
# 从datetime模块导入timedelta类, 用于时间间隔计算
from datetime import timedelta
# 定义配置类Config, 用于存储应用的各种配置项
class Config :
# 基础配置
# 设置应用密钥,优先从环境变量获取,如果没有则使用默认值'dev'
SECRET_KEY = os . environ . get ( ' SECRET_KEY ' ) or ' dev '
# 数据库配置
# 配置SQLAlchemy数据库连接URI, 使用PyMySQL驱动连接MySQL数据库
SQLALCHEMY_DATABASE_URI = ' mysql+pymysql://root:123456@127.0.0.1:3306/yangzhiappdb '
# 禁用SQLAlchemy的修改跟踪功能, 节省系统资源
SQLALCHEMY_TRACK_MODIFICATIONS = False
# 会话配置
# 设置永久会话的生命周期为7天
PERMANENT_SESSION_LIFETIME = timedelta ( days = 7 )
# 日志配置
# 设置日志文件存储路径, 位于项目根目录下的logs文件夹
LOG_PATH = os . path . join ( os . path . dirname ( os . path . abspath ( __file__ ) ) , ' logs ' )
# 如果日志目录不存在,则创建该目录
if not os . path . exists ( LOG_PATH ) :
os . makedirs ( LOG_PATH )