Quepinch

Create a HTTP server on your computer with just one command

Feb 17, 2021

Python makes it very easy to create a http server. All you need to do is hit one simple command. When you hit the following command in your terminal/shell it will start a server on port number: 8000. Although you can provide a different port number of your choice. Let's stick to this port number for the purpose of this tutorial.

In python 3:

python -m http.server 8000

In python 2:

python -m SimpleHTTPServer 8000

Follow the steps to run server in your laptop/computer:

  1. Open the terminal and navigate to any of the directory in which you want to run your server.
  2. Check the version of python. Try following command to check version of python: python --version.
  3. Run the corresponding command. If it's python version 3 or above then run python -m http.server 8000. Once you hit this command the server will start

Open the browser window and enter the following url: 
http://localhost:8000/.

Author
Rajat M