Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

A Simple Python Web Server to Echo Back HTTP Request Headers and Data

a-simple-python-web-server-to-echo-back-http-request-headers-and-data.jpg

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.

Quick Jump:

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.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments