The other day I was chatting with a co-worker and he pointed out a very simple command that could be used to quickly and easily share files with people within your LAN. This could also be used to share with people on the internets, but you’d have to configure NAT from your router. That much of the configuration is up to you, but I’ll share with you the quick ‘n easy webshare command.
The only requirement, as far as I can tell, is python. I’ve run it on my Linux machine as well as my OS X machine and it worked just fine with no other configuration or packages installed. It should likely work on anything else that has python installed as well.
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.