33 lines
717 B
Python
33 lines
717 B
Python
from typing import Optional
|
|
from pydantic_settings import BaseSettings
|
|
from functools import lru_cache
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""应用配置"""
|
|
# Confluence 配置
|
|
CONFLUENCE_BASE_URL: str = "https://confluence.westwell-lab.com"
|
|
CONFLUENCE_TOKEN: str = ""
|
|
ROOT_PAGE_ID: str = "137446574"
|
|
|
|
# 缓存配置
|
|
CACHE_DIR: str = "./cache"
|
|
CACHE_TTL: int = 3600 # 缓存有效期(秒)
|
|
|
|
# 应用配置
|
|
APP_HOST: str = "0.0.0.0"
|
|
APP_PORT: int = 8000
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
case_sensitive = True
|
|
|
|
|
|
@lru_cache()
|
|
def get_settings() -> Settings:
|
|
"""获取配置(单例)"""
|
|
return Settings()
|
|
|
|
|
|
settings = get_settings()
|