https://github.com/guillaumefalourd/webhooks-python
POC of sending and receiving webhooks in Python 🐍
https://github.com/guillaumefalourd/webhooks-python
devops flask python webhooks
Last synced: 7 months ago
JSON representation
POC of sending and receiving webhooks in Python 🐍
- Host: GitHub
- URL: https://github.com/guillaumefalourd/webhooks-python
- Owner: GuillaumeFalourd
- Created: 2021-12-14T13:22:24.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-14T14:05:19.000Z (almost 4 years ago)
- Last Synced: 2025-01-12T06:07:12.587Z (9 months ago)
- Topics: devops, flask, python, webhooks
- Language: Python
- Homepage: https://devopslifecycle.com/
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# webhooks-python
[](https://github.com/GuillaumeFalourd/webhooks-python/actions/workflows/security-pipeline.yaml) [](https://github.com/GuillaumeFalourd/webhooks-python/actions/workflows/webhook_remote.yaml)
POC of sending and receiving webhooks in Python 🐍
## References
- [How to Send Webhooks with Python](https://www.youtube.com/watch?v=X-_25tzo8Cw&ab_channel=DevOpsJourney)
- [How to Receive Webhooks with Python](https://www.youtube.com/watch?v=HQLRPWi2SeA&ab_channel=DevOpsJourney)## Usage
First, if you don't have the dependencies installed on your computer, run:
```shell
pip install -r requirements.txt
```* * *
### 📤 Sender (Remote)
You will be able to send a webhook request remotely running the `webhook_remote.py` file by using `python webhook_remote.py`.
[Check the request output here](https://webhook.site/#!/61a89a13-0f6d-4116-ae4d-95e4854683b3/c7169b86-9405-4dd9-9233-a87a19007210/1)
_Note: You can update the webhook online url on the `webhook_remote.py` file by creating your own for free on the [Webhook site](https://webhook.site/)._
#### Demo Sender (Remote)
```shell
➜ python webhook_remote.py
Success
```
* * *
### 📥 Receiver
You will be able to run the server by using `python server.py`.
#### Demo Receiver
```shell
➜ python server.py
* Serving Flask app 'server' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
```Accessing the `http://127.0.0.1:5000/` on your navigator, you'll see somthing like this:
* * *
### 📤 Sender (Local)
You will be able to send a webhook request locally to the server above running the `webhook_local.py` file by using `python webhook_local.py` (on another terminal than the one where the `server.py` script is running).
#### Demo Sender (Local)
```shell
➜ python webhook_local.py
Success
```If you do so, the terminal with the `server.py` script running will return the JSON it received:
```shell
➜ python server.py
* Serving Flask app 'server' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
{'name': 'Guillaume', 'phone': '+553499999-9999', 'email': 'guillaume@test.com'}
127.0.0.1 - - [14/Dec/2021 10:48:06] "POST /webhook HTTP/1.1" 200 -
```