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