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

Function reset_config

app/admin/api.py:487–515  ·  view source on GitHub ↗

将配置重置为 .env.example 并热重载。

()

Source from the content-addressed store, hash-verified

485
486@router.post("/config/reset", dependencies=[Depends(require_auth)])
487async def reset_config():
488 """将配置重置为 .env.example 并热重载。"""
489 try:
490 await reset_env_to_example(reload_callback=reload_settings)
491 logger.info("✅ 配置已重置为 .env.example 默认值")
492 return _with_hx_trigger(
493 _build_alert(
494 "配置已恢复为 .env.example 默认值,页面即将刷新。",
495 title="已重置!",
496 level="success",
497 ),
498 "admin-config-refresh",
499 )
500 except FileNotFoundError:
501 logger.error("❌ 未找到 .env.example,无法重置配置")
502 return _build_alert(
503 "未找到 .env.example,无法重置配置。",
504 title="错误!",
505 level="error",
506 status_code=404,
507 )
508 except Exception as exc:
509 logger.error(f"❌ 配置重置失败: {exc}")
510 return _build_alert(
511 f"重置失败: {exc}",
512 title="错误!",
513 level="error",
514 status_code=500,
515 )
516
517
518@router.get("/env-preview", dependencies=[Depends(require_auth)])

Callers

nothing calls this directly

Calls 3

reset_env_to_exampleFunction · 0.90
_with_hx_triggerFunction · 0.85
_build_alertFunction · 0.85

Tested by

no test coverage detected