2026-01-26 10:16:47 +08:00
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
from pydantic import Field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ⚠️ 注意: 您需要安装 pydantic-settings: pip install pydantic-settings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
|
|
|
|
"""
|
|
|
|
|
|
应用配置类。Pydantic Settings 会自动从环境变量和 .env 文件中加载这些值。
|
|
|
|
|
|
"""
|
|
|
|
|
|
model_config = SettingsConfigDict(
|
|
|
|
|
|
env_file='.env',
|
|
|
|
|
|
env_file_encoding='utf-8',
|
|
|
|
|
|
extra='ignore' # 忽略环境变量中多余的键
|
|
|
|
|
|
)
|
|
|
|
|
|
# 启动端口
|
2026-01-26 11:40:11 +08:00
|
|
|
|
SERVE_PORT: int = Field(default=10090, description='')
|
|
|
|
|
|
|
|
|
|
|
|
FLUX2_KLEIN_MODEL_PATH: str = Field(default="/models", description='')
|
|
|
|
|
|
|
2026-01-26 10:16:47 +08:00
|
|
|
|
# 调试配饰
|
|
|
|
|
|
LOCAL: int = Field(default=0, description="是否在本地运行,1表示本地运行,0表示生产环境运行")
|
|
|
|
|
|
|
|
|
|
|
|
# minio配置
|
|
|
|
|
|
MINIO_URL: str = Field(default="", description="URL")
|
|
|
|
|
|
MINIO_ACCESS: str = Field(default="", description="ACCESS")
|
|
|
|
|
|
MINIO_SECRET: str = Field(default="", description="SECRET")
|
|
|
|
|
|
MINIO_SECURE: bool = Field(default=True, description="SECRET")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 创建配置实例,供应用其他部分使用
|
|
|
|
|
|
settings = Settings()
|