MCPcopy Create free account
hub / github.com/ZyphrZero/z.ai2api_python / save_config

Function save_config

app/admin/api.py:417–448  ·  view source on GitHub ↗

保存结构化配置并热重载。

(request: Request)

Source from the content-addressed store, hash-verified

415
416@router.post("/config/save", dependencies=[Depends(require_auth)])
417async def save_config(request: Request):
418 """保存结构化配置并热重载。"""
419 try:
420 form_data = await request.form()
421 await save_form_config(
422 form_data,
423 reload_callback=reload_settings,
424 )
425 logger.info("✅ 结构化配置已保存")
426 return _with_hx_trigger(
427 _build_alert(
428 "配置已保存并热重载,页面即将刷新。",
429 title="保存成功!",
430 level="success",
431 ),
432 "admin-config-refresh",
433 )
434 except ValueError as exc:
435 return _build_alert(
436 str(exc),
437 title="校验失败!",
438 level="error",
439 status_code=400,
440 )
441 except Exception as exc:
442 logger.error(f"❌ 配置保存失败: {exc}")
443 return _build_alert(
444 f"保存失败: {exc}",
445 title="错误!",
446 level="error",
447 status_code=500,
448 )
449
450
451@router.post("/config/source", dependencies=[Depends(require_auth)])

Callers

nothing calls this directly

Calls 3

save_form_configFunction · 0.90
_with_hx_triggerFunction · 0.85
_build_alertFunction · 0.85

Tested by

no test coverage detected