Download app/api/v1/admin_api/config.py from f2d90b38/ggload: direct link, hf CLI and curl.
- Browser
- Download file 1.68 kB
-
https://huggingface.co/spaces/f2d90b38/ggload/resolve/main/app/api/v1/admin_api/config.py
- Command line
-
hf download hf://spaces/f2d90b38/ggload/app/api/v1/admin_api/config.py
-
curl -L -o config.py https://huggingface.co/spaces/f2d90b38/ggload/resolve/main/app/api/v1/admin_api/config.py
1.68 kB
| import os | |
| from fastapi import APIRouter, Depends, HTTPException | |
| from app.core.auth import verify_app_key | |
| from app.core.config import config | |
| from app.core.storage import get_storage, LocalStorage, RedisStorage, SQLStorage | |
| router = APIRouter() | |
| async def admin_verify(): | |
| """验证后台访问密钥(app_key)""" | |
| return {"status": "success"} | |
| async def get_config(): | |
| """获取当前配置""" | |
| # 暴露原始配置字典 | |
| return config._config | |
| async def update_config(data: dict): | |
| """更新配置""" | |
| try: | |
| await config.update(data) | |
| return {"status": "success", "message": "配置已更新"} | |
| except Exception as e: | |
| raise HTTPException(status_code=500, detail=str(e)) | |
| async def get_storage(): | |
| """获取当前存储模式""" | |
| storage_type = os.getenv("SERVER_STORAGE_TYPE", "").lower() | |
| if not storage_type: | |
| storage = get_storage() | |
| if isinstance(storage, LocalStorage): | |
| storage_type = "local" | |
| elif isinstance(storage, RedisStorage): | |
| storage_type = "redis" | |
| elif isinstance(storage, SQLStorage): | |
| storage_type = { | |
| "mysql": "mysql", | |
| "mariadb": "mysql", | |
| "postgres": "pgsql", | |
| "postgresql": "pgsql", | |
| "pgsql": "pgsql", | |
| }.get(storage.dialect, storage.dialect) | |
| return {"type": storage_type or "local"} | |