Monday, March 9, 2015

How to quickly transfer your files between computers using Python SimpleHTTPServer

Sometimes we need to share a file quickly in a folder with a colleague while at work.

Well if you have apple devices, you can quickly share files and folders with AirDrop.

But what if you have a mix of operating systems and you don't have a portable HDD or a USB
pen drive at vicinity?

If you have python installed in your operating system by default,
here's how to do it quickly and easily...

Two computers I'm using are having OS X Yosemite and Ubuntu operating systems.
I'm trying to share a file in a given folder at my OS X Mac and download it from a web browser from my friend's ubuntu computer.

From my computer

1. Go to the folder from a terminal session.

2. Find the IP address of the computer that the file is in.
> ifconfig
Note: my IP is

3. Issue the following command to start the python SimpleHTTPServer.
> python -m SimpleHTTPServer
Note: server starting on port 8000 [1].

From my friend's computer

4. From the ubuntu computer ( open web browser and access the following URL.

5. Select the file you want and download.

Note: observe the request coming to the python SimpleHTTPServer from terminal [2].

Suhans-MacBook-Pro:compressed suhanr$ python -m SimpleHTTPServer
Serving HTTP on port 8000 ...
[2] - - [10/Mar/2015 10:14:27] "GET / HTTP/1.1" 200 - - - [10/Mar/2015 10:14:27] code 404, message File not found - - [10/Mar/2015 10:14:27] "GET /favicon.ico HTTP/1.1" 404 - - - [10/Mar/2015 10:14:33] "GET / HTTP/1.1" 200 -