Sometimes you just need to hand a file to another machine. If Python 3 is installed, one command turns a directory into a small web server.
Starting it
Go to the directory you want to share, then run:
$ cd ~/share
$ python3 -m http.server 8000 --bind 127.0.0.1
Serving HTTP on 127.0.0.1 port 8000 (http://127.0.0.1:8000/) ...-m http.server runs the module. 8000 is the port, and is also the default. --bind 127.0.0.1 accepts connections from this machine only.
Without --bind, it listens on all interfaces, so others on the network can reach it. To share with another computer, bind to your LAN address:
$ python3 -m http.server 8000 --bind 192.168.1.25Newer Python versions also accept --directory to serve a folder without changing into it:
$ python3 -m http.server --directory ~/shareFetching files
Open http://192.168.1.25:8000/ in a browser, or use:
$ curl -O http://192.168.1.25:8000/report.txtIf the directory has no index.html, visitors see a file listing. If it has one, that page is shown instead.
The terminal logs each request:
192.168.1.30 - - [29/Nov/2026 10:15:02] "GET /report.txt HTTP/1.1" 200 -Status 200 means success and 404 means not found.
If the other machine cannot connect, check the address you bound to and whether a firewall blocks the port.
Stay safe
Press Ctrl+C to stop the server.
The Python documentation warns that this module is not recommended for production. Started this way, it uses plain HTTP with no encryption and asks for no password. Python 3.14 added TLS options, but the warning still applies. Never start it in your home directory or /, where it could expose SSH keys and other private files. Make a dedicated folder, copy in only what you need, and stop the server when done.
Downloads work, but the basic server does not accept uploads.
Try it
- Make a folder
~/sharecontaining a small text file. - Start the server bound to
127.0.0.1. - In another terminal, run
curl http://127.0.0.1:8000/and watch the log, then stop the server.
Check your understanding
Simple HTTP Server
All 4 sections ยท no timer
Unlimited retries
Questions from every section are combined into one assessment. Answer them all correctly to complete the article.
Your completion saves in this browser. Sign in to sync it to your account.