Skip to content

Instantly share code, notes, and snippets.

@tangoabcdelta
Created October 20, 2025 15:05
Show Gist options
  • Select an option

  • Save tangoabcdelta/1ff723d69181e4bdb62817cdd1814279 to your computer and use it in GitHub Desktop.

Select an option

Save tangoabcdelta/1ff723d69181e4bdb62817cdd1814279 to your computer and use it in GitHub Desktop.
Create SimpleHTTPServer using Python

SimpleHTTPServer

The command python -m simplehttpserver starts a simple HTTP server in Python 2 that serves files from the current directory.

However, this module was removed in Python 3.

For modern Python, you should use the http.server module instead.

How to use http.server in Python 3

1. Navigate to the desired directory: Open a terminal or command prompt and change your working directory to the one containing the files you want to serve.

2. Run the command: Execute the following command to start the server.

python3 -m http.server

3. Specify a port (optional): By default, the server runs on port 8000. To use a different port, provide the number as an argument.

python3 -m http.server 8080

4. Access the server: Open a web browser and navigate to http://localhost:8000 (or the port number you specified). You will see a directory listing of the files you are serving.

4. Finding the IP of the server: In windows, to find the IP address, you can use ipconfig and for mac, you can use ifconfig | grep inet


Security warnings

  • Not for production: Python's simple HTTP server is intended for development and file sharing on a local network. It lacks robust security features and is not suitable for public-facing or production environments.
  • Data exposure: Be aware that running this command exposes all files and subdirectories in the working directory to anyone on the same network.
  • Firewall: Whenyou launch it in a Windows PC, it may require you to allow permission through a firewall.
  • HTTP and not HTTPS: When you download the files, let's say, on a phone, then you may get an error prompt advising you that the connection is not secure and download over https is not available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment