A Simple Python Web Server to Echo Back HTTP Request Headers and Data
In this video we'll go over how you can use this tool to test your app's webhooks but you can use it for other things too.
I recently found myself doing contract work where a service I’m creating had to send a webhook request to another service, but I’m not in control of that other service so I wanted a quick way to make sure my app is sending the correct headers and payload out in its webhook.
About 10 minutes later this Python tool was born.
# Demo Video of Using the Web Server
Timestamps
- 0:21 – Testing webhooks is one use case for using this tool
- 1:08 – Taking a quick peek at the Python code to make it work
- 1:33 – Sending a basic GET request with curl
- 2:41 – Sending a POST request with a JSON payload using curl
- 3:35 – A quick aside to send JSON data from a file
- 4:30 – Sending a POST request with form data using curl
- 5:22 – Connecting to the web server from a Dockerized web app
- 8:39 – It’s up on GitHub along with documentation
- 9:01 – Using ngrok to make the web server accessible on the internet
Reference Links
Are you going to use this script? If so for what? Let us know below.