Simply serve local directory via HTTP with python webserver 1


Sometimes you quickly need to exchange some files between networked machines. A really easy way that mostly also works through firewalls is to serve them via a local webserver. Python offers a really simple module for that:

python -m SimpleHTTPServer

To serve a local directory just run:


[email protected]:~$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

The IP “0.0.0.0” means that your webservers listens on every IP address that is bound to your network interfaces. You can find your IP with the command /sbin/ifconfig


[email protected]:~$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:11:22:33:44:55
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0

And then point your browser (or wget / curl) the IP with port 8000 – so in this case to http://192.168.1.2:8000.
You will get a directory listing and you can download files.


[email protected]:~$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
127.0.0.1 - - [13/Feb/2015 08:51:17] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [13/Feb/2015 08:55:56] "GET /Documents/work/sample.txt HTTP/1.1" 200 -


Leave a comment

Your email address will not be published. Required fields are marked *

One thought on “Simply serve local directory via HTTP with python webserver