Madhav Kobal's Blog

This blog will be dedicated to Linux, Open Source and Technology news, affairs, how-tos and virtually EVERYTHING in these domains.

Instant web File Sharing With python

Posted by madhavkobal on 02/09/2009

To share the contents of any folder on your machine simply run:

python -c "import SimpleHTTPServer; SimpleHTTPServer.test();"

You can run that one-liner anywhere on your file system and then access the files via your browser. Simply point your browser to your LAN IP port 8000 and you should see an index listing of the files.

To make this a little simpler I made it an alias in my .bashrc file. Just add this line somewhere in your .bashrc or .bash_aliases:

alias webshare='python -c "import SimpleHTTPServer; SimpleHTTPServer.test();"'

At this point you can simply run the command webshare anywhere on your file system and share those files. This makes for a really simple tool  for sharing files quickly and un-sharing them as soon as you’re done. Just hit ctrl-c to cancel and close the process.

Advertisements

Leave a Reply

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

 
%d bloggers like this: