import gradio as gr from huggingface_hub import WebhooksServer, WebhookPayload from model import model webhook_payload = None with gr.Blocks() as ui: gr.Markdown(f"## Hugging Face Webhooks Demo\n\n{webhook_payload.json() if webhook_payload is not None else ''}") progress = gr.Progress(track_tqdm=True) # 2. Create WebhooksServer with custom UI and secret app = WebhooksServer(ui=ui, webhook_secret="test") @app.add_webhook async def train(payload: WebhookPayload): webhook_payload = payload print("Received payload:", payload.dict()) return payload.dict() # 5. Start server (optional) app.run()