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 10.100.5.175

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 (10.100.0.101) open web browser and access the following URL.
http://10.100.5.175:8000/

5. Select the file you want and download.


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

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



No comments:

Post a Comment