Easy file sharing with Python

I have previously blogged about On-demand Web Server with Python, which is great to serve files you want people (or even yourself, remotely) to download from your computer. Unfortunately, it is unidirectional: people cannot upload files back to you. Luckily, that’s what we are going to address in this post!

One day I was determined to make file uploads work, and started Googling. I didn’t really find out an easy way to do this, but found two very friendly scripts that do exactly this. They’re only a single file, so it is very easy to “install”: just place them somewhere convenient and put it in your PATH environment variable. (Personally, I just copied them to /usr/local/bin)

droopy

The first one is also unidirectional, but on the direction that complements the trick in the previously mentioned post. Droopy allows you to open a web server that displays a single upload file field. Simple as that.

You can just run it without any parameters and receive files on the current working directory, or you can configure the directory and port, along with a display message and even a picture that will show up on the page for your uploaders.

Also, don’t worry about them overriding your files. A quick test will show you that droopy will append numbers to files that would otherwise overwrite your original ones.

quickserve

This one allows file sharing in both directions: download and upload. Quickserve is a little bit more verbose than previous solutions, but not inconvenient in any way.

To serve files, you must provide a upload directory as a command-line parameter, but a smart user will just type in “.” for the current working directory. To serve them, you will need to type in a bit more: --upload=. but perfectly manageable.

Differently from droopy, quickserve will overwrite files by default. This could be a desireable feature, just maybe not as default. To avoid this, add --no-clobber to your command line and numbers will be appended to them.

An ideal command line would be as long as quickserve . --upload=. --no-clobber, but nothing you can’t keep on a conveniently placed shell script.

Conclusions

Droopy is probably your first choice because of its simplicity, but quickserve is a much more complete solution, so I’d grab them both and decide which one to use depending on the situation.

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: