first cimmit
This commit is contained in:
32
app/config/config.py
Normal file
32
app/config/config.py
Normal file
@@ -0,0 +1,32 @@
|
||||
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' # 忽略环境变量中多余的键
|
||||
)
|
||||
# 启动端口
|
||||
SERVE_PROD: int = Field(default=8000, description='')
|
||||
# 调试配饰
|
||||
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()
|
||||
Reference in New Issue
Block a user