File size: 1,629 Bytes
51aeff1
 
0b66ecf
 
 
efc7a8e
 
 
0b66ecf
51aeff1
 
efc7a8e
ad2e859
e7d09e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26dfc12
e7d09e5
 
 
 
 
26dfc12
e7d09e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: Spaces Ci Bot
emoji: 👁
colorFrom: yellow
colorTo: red
sdk: gradio
sdk_version: 3.17.0
app_file: app.py
pinned: true
---

## Spaces CI webhook

This is a webhook space to build temporary Spaces when a PR is submitted.

## gradio_webhooks

This is also a PoC for a `gradio_webhooks` helper library. It uses Gradio to launch a server and register webhooks on it.

The major goal is to make the development process as easy as possible:
- debug your webhooks locally using a Gradio URL
- push your webhook server to a Gradio Space once ready

Features:
- Server app with `GradioWebhookApp`
- Debug locally before deploying on Spaces
- Handle `x-webhook-secret` header
- Output is parsed as `WebhookPayload` (to be completed)
- Landing page to render README (or markdown page)

### Quick example:

**app.py**

```python
from gradio_webhooks import GradioWebhookApp, WebhookPayload

app = GradioWebhookApp(webhook_secret="my_dummy_secret")


@app.add_webhook("/my_webhook")
async def hello(payload: WebhookPayload):
    print(f"Received webhook for repo {payload.repo.name}")
    return {"processed": True}


app.ready()
```

**Output in terminal**

```text
Running on local URL:  http://127.0.0.1:7860
Running on public URL: https://18ffc05a-d0bf-4041.gradio.live

This share link expires in 72 hours. For free permanent hosting and GPU upgrades (NEW!), check out Spaces: https://huggingface.co/spaces

Webhook secret is correctly defined.

Webhooks are correctly setup and ready to use:
  - POST https://18ffc05a-d0bf-4041.gradio.live/my_webhook
Go to https://huggingface.co/settings/webhooks to setup your webhooks.
```