🛜 Sharing a folder over Wi-Fi with Python: the http.server command trick

 

When you need to quickly share a folder on your PC with other devices connected to the same Wi-Fi network, you often think of complicated solutions: configuring Windows Sharing, using cloud services, installing dedicated software... In reality, there is a very simple trick, already included in Python, that allows you to transform any folder on your computer into a small local web server: just a single command.

In this article, we'll see how it works, what requirements it requires, and how to use it as quickly as possible.

🔗 Do you like Techelopment? Check out the site for all the details!

Why use http.server

The http.server module included in Python allows you to start a minimal web server in seconds. It's designed for testing and development, but it's also perfect for sharing files within your local network:

  • no additional installation
  • works on Windows, macOS, and Linux
  • just one terminal command is enough
  • instant access via browser (Chrome, Firefox, Safari, etc.)

Requirements

To use this trick, you only need:

  • Python installed on your PC
    Any recent version is fine (Python 3.x).
    To check if it's present, open a terminal or command prompt and type:
    python --version
    or, on Some systems:
    python3 --version
  • A Wi-Fi network to which both the PC and the devices that need to access the files are connected
  • Firewall permissions for Python
    The first time, Windows or macOS may ask for permission to allow Python to accept incoming connections. Just confirm.


How to make a folder accessible via Wi-Fi with a command

1. Open the command prompt / terminal

- On Windows: Search for "cmd" or "Command Prompt"
- On macOS/Linux: Terminal

2. Navigate to the folder you want to share

For example:

cd C:\Users\UserName\Documents\Sharing

or on Mac/Linux:

cd ~/Documents/Sharing

3. Start the server with Python

Run this command:

python -m http.server 9090 --bind 0.0.0.0

What do the parameters mean?

  • -m http.server → starts the web server built into Python
  • 9090 → this is the port the server will listen on (you can change it)
  • --bind 0.0.0.0 → makes the server accessible from other devices on the network, not just the local PC

4. Find your computer's IP address

To make the folder accessible, the device that wants to connect to it must know the IP address of your PC on the local network.

- Windows:

ipconfig

Look for "IPv4 Address".

- macOS/Linux:

ifconfig

or

ip addr

AndExample address: 192.168.1.42

5. Access the folder from another device

From the browser on your smartphone, tablet, or another PC (connected to the same Wi-Fi network), type:

http://192.168.1.42:9090

A list of files in the folder from which you launched the command will automatically appear.

To stop sharing

Return to the terminal where the server is active and press:

CTRL + C

Troubleshooting

If other devices are unable to connect, the problem is often the firewall blocking the port used (in this example, 9090). Below are two methods to enable incoming traffic on Windows Defender Firewall for port 9090.

Graphical Method (Windows Defender Firewall — Windows Security)

  1. Open Windows Security (search for "Windows Security" in the Start menu).
  2. Go to Firewall and network protection.
  3. Scroll down and click Advanced Settings. This opens the "Windows Defender Firewall with Advanced Security" console. (You may be asked for administrator permissions.)
  4. In the left panel, click Inbound Rules.
  5. On the right, click New Rule....
  6. Choose Port and click Next.
  7. Select TCP and Specific local ports, enter 9090, then Next.
  8. Select Allow the connection and Next.
  9. Choose the profiles to apply the rule to (usually check Private and Domain if you're on a trusted network; avoid checking Public unless necessary).
  10. Set Enter a descriptive name, such as Python HTTP Server 9090, and click Finish.

Windows Defender should now allow incoming TCP connections on port 9090 from the selected network segment.

Command-line method (administrative prompt)

Open Command Prompt as administrator (right-click → Run as administrator) and run this command:

netsh advfirewall firewall add rule name="Python HTTP Server 9090" dir=in action=allow protocol=TCP localport=9090

This will immediately create an inbound rule that allows TCP traffic on port 9090.

Additional checks

  • Make sure your PC and client device are connected to the same Wi-Fi network and not to separate guest networks or VLANs that isolate clients.
  • If your PC uses an antivirus with its own firewall (other than Windows Defender), enable the port there as well or create the same rule.
  • Verify that the Python server is actually listening on the correct port and the IP 0.0.0.0 (the terminal displays the output when you run the command).
  • If you continue to have problems, try changing the port (e.g., 8080 or 8000) and repeat the firewall procedure for the chosen port.

Helpful Tips

  • You can share any folder, even on a USB stick.
  • Changing the port can be useful if you already use services on the default port (e.g., python -m http.server 8080).
  • The server is suitable for trusted networks: do not use it for public or permanent sharing, as it does not include passwords or encryption.

Conclusion

With a single command and without installing anything, Python offers a lightning-fast way to share files over Wi-Fi within the same network. It's a perfect trick for quick transfers between PCs and smartphones, for showing projects to colleagues, or for accessing your files without cables or cloud services.



Follow me #techelopment

Official site: www.techelopment.it
facebook: Techelopment
instagram: @techelopment
X: techelopment
Bluesky: @techelopment
telegram: @techelopment_channel
whatsapp: Techelopment
youtube: @techelopment