- 添加保存图片到jfile/files目录的功能 - 返回结果从image_content改为image_url - 添加save_dir和download_url配置项 - 大幅减少返回数据大小,提升传输性能 - file和batch接口均支持返回图片URL
37 lines
953 B
Python
37 lines
953 B
Python
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
|
|
|
|
class Config:
|
|
env_file = ".env"
|
|
|
|
@lru_cache()
|
|
def get_settings() -> Settings:
|
|
return Settings()
|
|
|
|
# 创建全局配置实例
|
|
settings = get_settings() |