In this post we will learn how to launch the built-in-web server in Python.
What is a SimpleHTTPServer?
The SimpleHTTPServer module is an in-built web server in Python that provides standard GET and HEAD request handlers. The SimpleHTTPServer module has been merged into http.server in Python 3.
- A Computer
- Python installed (If not, click here)
- Working Internet Connection
How to start?
- Open Command Prompt on Windows.
- Press Win-Key + R and type cmd and skip step 1.
- In your terminal, cd into whichever directory you wish to have accessible via browsers and HTTP.
- Now, type python -m http.server [port] (can use the default port: 8000) and enter. Voila! Your built-in Python web server is running.
- Open your favorite browser and type http://localhost:8000 or http://127.0.0.1:8000
- If you don’t have an index.html file in the directory, then all files and directories will be listed.
- Check your terminal. You should see standard http logging informations. It will update as long as http server is running.
Simple and Easy-to-Launch
You don’t have to install or configure anything. The only thing you need is Python installed. This makes launching a simple web server in less than a minute. While there are many web server softwares out there (apache, nginx) but running built-in Python web server is really easy.
If this post was helpful, share this on your social circles. Comment down below if you face any issues.