Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Simple HTTP Server that concentrates on behaviour and response/status codes, not response content.

Notifications You must be signed in to change notification settings

dhutty/pythonhttp

Open more actions menu

Repository files navigation

A little demo code that shows how easy it is to create a simple, but useful custom webserver in Python.

I wrote this originally for someone in a chat who wanted to return a specific HTTP response code to every request and am publishing only because I've written code that looks much like this at least once before, so this will make it faster if I need something like it again.

  • Subclasses BaseHTTPRequestHandler

  • Threaded, if python3.7+

  • Hand it an SSL cert and a private key, you have SSL support

  • Containerized

      docker build -t pythonhttp .
      docker run --rm -P pythonhttp -- --responsecode 204
    
  • See --help for optional behaviours, including delaying reponse and changing status codes.

Note that I do not consider this to be production quality code or suitable for purposes in any way serious. This is for demonstration purposes only.

About

Simple HTTP Server that concentrates on behaviour and response/status codes, not response content.

Resources

Stars

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.