japi/apps/rmbg/settings.py

40 lines
1.1 KiB
Python
Raw 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.

from pydantic_settings import BaseSettings
from typing import Optional
from functools import lru_cache
class Settings(BaseSettings):
# Japi Server 配置
host: str = "0.0.0.0"
port: int = 8106
debug: bool = False
# API路由配置
router_prefix: str = "/rmbg"
file_route: str = "/file"
batch_route: str = "/batch"
api_name: str = "remove_background"
upload_url: str = "http://images.jingrow.com:8080/api/v1/image"
# 图片保存配置
save_dir: str = "../jfile/files"
# Japi 静态资源下载URL
download_url: str = "https://api.jingrow.com/files"
# Jingrow Jcloud API 配置
jingrow_api_url: str = "https://cloud.jingrow.com"
jingrow_api_key: Optional[str] = None
jingrow_api_secret: Optional[str] = None
# 并发控制配置
max_workers: int = 30 # 线程池最大工作线程数根据CPU核心数调整22核44线程可设置20-30
class Config:
env_file = ".env"
@lru_cache()
def get_settings() -> Settings:
return Settings()
# 创建全局配置实例
settings = get_settings()