Quick and easy sharing of a directory over HTTP in Linux

By | January 13, 2009

Say you want to share a folder for a friend. What better way than pointing him to an URL? Put this in your .bash_profile and login to your account.

alias webshare=‘python -c “import SimpleHTTPServer;SimpleHTTPServer.test()”‘

Now cd to the directory in question a do a simple webshare command. That folder will be accessible from any browser by typing http://your_ip:8000
Alternatively, you can use Droopy.

7 thoughts on “Quick and easy sharing of a directory over HTTP in Linux

  1. Pingback: Easy way to send files from Windows to Linux « Linux & Stuff

  2. Dafydd Walters

    Another alternative for this sort of thing is ‘Woof’ (http://www.home.unix-ag.org/simon/woof.html), which allows a file to be served via HTTP. It also works with directories, but in that instance Woof serves a tarball of the contents of the specified directory as a single file. Woof is also able to serve up a copy of itself, enabling the other party to subsequently offer a file back to you.

    Reply
  3. Smitty

    Of course you ignore all the firewall and directory/file permission issues, but hey, let’s not quibble about such trivialities

    Reply
  4. T4L Post author

    This tip wasn’t about firewall configuration. It’s just like saying about a mencoder tip that the text doesn’t mention you can also use ZSH to do the job.

    Reply
  5. Smitty

    My point is – there is no such thing as a “Quick and easy sharing of a directory over HTTP in Linux”, unless you also want to run in a completely unsecured environment. I’ll agree that the one liner to set up the http share is trivial, but then so is adding a Samba share, or an SFTP folder, or for that matter, a WebDav share. All of these activities could also be performed by a single shell commandline (although they would involve multiple commands on the single line.) Don’t get me wrong; it’s good to see articles like this that help people understand the types of tools that are available but I think you have trivialized the issue by not mentioning the other aspects of making files public.

    Reply
  6. Michael

    Great tip, but actually python’s SimpleHTTPServer and Droopy have opposite uses. As you state, this webshare alias will allow others to retrieve files FROM you computer. Droopy is only for others to upload files TO your computer.

    Reply
  7. miss juicy

    Please send me some tips on urls and other codes as well.Lost my notes actualy they were stolen from my room? Go figuare?

    Reply

Leave a Reply

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