POC of sending and receiving webhooks in Python π
First, if you don't have the dependencies installed on your computer, run:
pip install -r requirements.txt
You will be able to send a webhook request remotely running the webhook_remote.py
file by using python webhook_remote.py
.
Note: You can update the webhook online url on the webhook_remote.py
file by creating your own for free on the Webhook site.
β python webhook_remote.py
Success
You will be able to run the server by using python server.py
.
β 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:
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).
β python webhook_local.py
Success
If you do so, the terminal with the server.py
script running will return the JSON it received:
β 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 -