Run a http server from any directory on Linux

cool_penguin_smallMany a time we need to share files over the LAN. There is a very simple way of doing it when you are on Linux using python2. cd to the directory the contents of which you want to share and run:

//Python 2
$ python -m SimpleHTTPServer 8181

//Python 3
$ pyhton3 -m http.server 8181

Here, 8181 is the arbitrary port number you want to use for your HTTP server. The files can now be accessed from any system in the LAN using a browser at

http://YOUR_IP_ADDRESS:8181

Another interesting utility is nweb.

Tested it between my laptop and mobile over the wireless and worked fine. Happy sharing!

2 thoughts on “Run a http server from any directory on Linux”

  1. This only works for python2. Version 3 uses a different module (python3 -m http.server)

    The best part about this is that it works on a lot more than just Linux (like the BSDs or on a mac)

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s