Files

37 lines
1.3 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.
# config.py
# 全局配置:通过环境变量覆盖,便于 Docker 部署时注入
import os
class Settings:
"""集中管理项目配置,生产环境请通过环境变量覆盖默认值"""
# ---------- 应用 ----------
APP_NAME: str = "沃林学生管理系统"
APP_VERSION: str = "1.0.0"
DEBUG: bool = os.getenv("DEBUG", "false").lower() == "true"
# ---------- 数据库 ----------
DATABASE_URL: str = os.getenv(
"DATABASE_URL",
# 默认本地开发环境:请替换为你自己的 MySQL 信息
"mysql+pymysql://root:123456@localhost:3306/walin_db?charset=utf8mb4",
)
DB_ECHO: bool = os.getenv("DB_ECHO", "false").lower() == "true"
# ---------- JWT ----------
SECRET_KEY: str = os.getenv(
"SECRET_KEY",
"CHANGE_ME_IN_PRODUCTION_please_use_a_long_random_string_here",
)
JWT_ALGORITHM: str = "HS256"
# token 有效期(分钟),默认 12 小时
ACCESS_TOKEN_EXPIRE_MINUTES: int = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", "720"))
# ---------- 初始管理员(仅用于 seeding 参考,见 sql/init.sql) ----------
ADMIN_USERNAME: str = os.getenv("ADMIN_USERNAME", "admin")
ADMIN_PASSWORD: str = os.getenv("ADMIN_PASSWORD", "admin123")
settings = Settings()