How to make a simple HTTP server using python?

Aditya Nama
3 min readAug 22, 2021

--

Hey!

In this blog, we are going to learn how to set up a simple and local HTTP server using Python. An HTTP server can be very useful for sharing files across multiple devices connected over the same network & for testing Web apps locally during development.

To start with,

  1. Install Python. If you are using Linux or macOS, it should be available on your system already. If you are a Windows user, you can get an installer from https://www.python.org/downloads/.

Download the latest version -> While installing, go by default options -> Make sure you check the “Add Python to PATH” checkbox.

2. Open Command Prompt/Terminal. To check if Python is installed, enter the following command:

python -V
python3 -V
Kali OS Screenshot(By default, kali has both versions of python installed)
Windows 10 Screenshot

3. Navigate to the directory you want to share using CMD or Terminal (Example: cd Desktop/Test/)

4. Depending upon the python version installed:

#For python 2 use the following command:

python -m simpleHTTPServer#By Default the port is 8080python -m simpleHTTPServer 1234
(port)
Note: If you already have something running on port 8000, you can choose another port by running the server command followed by an alternative port number

#For python 3 use the following command:

python3 -m http.server #By Default the port is 8080python3 -m http.server 1234
(port)
Note: If you already have something running on port 8000, you can choose another port by running the server command followed by an alternative port number

Allow python through firewall only on private networks if it is not.

5. By default, this will run the contents of the directory on a local web server, on the selected port. You can go to this server by going to the URL http://localhost:1234 or http://ip:1234 in your web browser.

We have successfully created the local server

You can access http://ip:1234 from any device using the same network.

Thanks for reading! 😊

--

--

Aditya Nama
Aditya Nama

Written by Aditya Nama

Security Engineer | AWS Community Builder

Responses (2)