The age old problem: how do I send you these files with the least amount of effort. Have you ever been is this situation? You need to send bunch of files to another person sitting 3 feet away from you. Neither one of you is carrying any portable media. No thrumb drives, not blank CD’s or anything like that. What you do have is network connectivity.
The first thing people do in a situation like this is to reach for their email. Unfortunately email was never designed to be a file sharing medium. If you have a large number of big files to send over, email will not work. You could use one of the online file sharing services such as SendSpace or Rapidshare but they too have arbitrary file size limitations. Not only that, but your data will now be stored somewhere on the interwebs – in many cases this is unacceptable.
What do you do then?
A while ago I wrote about one possible solution to this problem – a mini HTTP server. That was a windows centric solution that used a proprietary freeware tool. Recently I discovered a much nicer solution that requires nothing but a standard Python installation.
Here is what you do. On the command line, navigate to the folder you want to share over the network, and issue the following command:
python -m SimpleHTTPServer 80
Boom! Instant HTTP server. All you need to do now is to instruct the other person to open a web browser and type in your current IP into the address bar. Easy, painless and awesome. Here is me running the server and accessing it at the same time:
As you can see, the server will actually show you information about every access attempt so you can have some evidence that no one but the authorized person accessed it while it was running.
Still, sharing the whole folder is not always desirable. Sometimes you want to transfer just a single big file. If you recall, I already shown you how to do this with Netcat. I’m going to continue with the Python centric theme and introduce you to a neat little script called woof.
Using it is very simple. Just do this:
python woof.py MyFileToBeShared.zip
That’s it. It creates a server on port 8080 and serves that particular file and nothing else. One disadvantage of this script seems to be that it seems to rely on something POSIX-y to work. In other words, it fails miserably in Windows environment but it should work in a real operating system.
Of course, sometimes you are in a reverse situation. Instead of having to send files, you need to receive them. Running a miniature HTTP server won’t help you. Or maybe it will. What you need is Droopy – another Python mini server. Instead of serving files however, it creates a file upload page that looks like this:
You can customize how this page looks by displaying a custom message and ever a picture below the upload form. But this is how it works. It is quite brilliant actually. Run it, tell the other person to navigate to your IP on port 8000 and upload the file. Very simple and very effective.
Keep these things in mind during your travels. I’d recommend installing Python to be the first thing you do whenever you get a new laptop.
What are your favorite python tricks? Or network file transfer tricks in general?