INNER CODE UNIT · Python
admin_reload_config
SPThole/CoexistAI · app.py:208
async def admin_reload_config(request: Request):
"""Reload model config from the configured JSON file. Protected by ADMIN_TOKEN env var.
Send header 'X-Admin-Token: <token>' to authenticate. Returns the reloaded config on success.
"""
token = request.headers.get('X-Admin-Token')
try:
_check_admin_token(token)
except HTTPException as e:
raise e
try:
new_cfg = reload_model_config()
except Exception as e:
raise HTTPException(status_code=500, detail=f'Failed to reload config: {e}')
# apply config immediately
try:
init_components()