Python has a built-in HTTP server which can be used to serve static content on the local machine or in the local network. It is just a plain web server. Obviously, it does not support server-side scripting.

It turns out that even such a primitive tool can be useful sometimes. When did I use it?

When I had documentation in the form of a web page and wanted to share it conveniently with someone who was connected to my home network without bothering to find a web hosting. After all, I needed it only for a few minutes.

It was also helpful when I had a script to build a static web page and wanted to test the result.

How to run it?

python -m http.server <port number>

for example:

python -m http.server 8080

It will serve the content from the current directory.

Important note: it must not be used in production or when the machine is connected to public networks because it is not very secure.

Subscribe to the newsletter
Older post

Assert Object Pattern: A Simple Technique to Make Your Tests More Readable

A simple pattern that makes your tests more readable

Newer post

Understanding uncertainty intervals generated by Prophet

How to tweak uncertainty intervals in Prophet.