19 lines
413 B
Python
19 lines
413 B
Python
|
|
"""
|
||
|
|
应用配置 — 用 pydantic-settings 的 BaseSettings 读取 .env
|
||
|
|
"""
|
||
|
|
|
||
|
|
from pydantic_settings import BaseSettings
|
||
|
|
|
||
|
|
|
||
|
|
class Settings(BaseSettings):
|
||
|
|
DATABASE_URL: str
|
||
|
|
SECRET_KEY: str = "change-me-to-a-random-string-in-production"
|
||
|
|
SESSION_MAX_AGE: int = 86400 # 秒,默认 1 天
|
||
|
|
|
||
|
|
model_config = {
|
||
|
|
"env_file": ".env",
|
||
|
|
"env_file_encoding": "utf-8",
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
settings = Settings()
|