Simple HTTP server using Python

I’m not a Python pro, I use it mostly for REST API interactions so this might be a “discovering America” type of post for some of you but I found it super interesting and useful! And no, it’s not about writing a web server in Python. It’s about starting a built-in one that comes with every Python installation, whether you’re using a Linux, MacOS or Windows.

Using cmd, shell or terminal just enter a directory you would like to become a root folder of your temporary web server:

cd /usr/rnorwa/Desktop/www_root

Then start the web server on a chosen port using this command:

python -m SimpleHTTPServer 8080

The server provides standard GET and HEAD request handlers so you can use it for file sharing, simple HTML websites and general testing. I used it for UAG web reverse proxy testing. It works over localhost and regular IP in your network.

You can find out more details in official Python 3 documentation


If you wish to bind the server to specific IP address (localhost for instance) you can use this syntax:

python3 -m http.server --bind 8000

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s