feat: 重构API服务器,添加配置重载功能并移除冗余代码
This commit is contained in:
@@ -1 +0,0 @@
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
from rich.traceback import install
|
||||
|
||||
install(extra_lines=3)
|
||||
|
||||
# 创建APIRouter而不是FastAPI实例
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("/reload-config")
|
||||
async def reload_config():
|
||||
try: # TODO: 实现配置重载
|
||||
# bot_config_path = os.path.join(BotConfig.get_config_dir(), "bot_config.toml")
|
||||
# BotConfig.reload_config(config_path=bot_config_path)
|
||||
return {"message": "TODO: 实现配置重载", "status": "unimplemented"}
|
||||
except FileNotFoundError as e:
|
||||
raise HTTPException(status_code=404, detail=str(e)) from e
|
||||
except Exception as e:
|
||||
raise HTTPException(status_code=500, detail=f"重载配置时发生错误: {str(e)}") from e
|
||||
@@ -1,4 +0,0 @@
|
||||
import requests
|
||||
|
||||
response = requests.post("http://localhost:8080/api/reload-config")
|
||||
print(response.json())
|
||||
Reference in New Issue
Block a user