Unordered List

Wednesday, April 18, 2012

How To Share Files Across Your Home Network Using Python

All of us will ever be at home with a friend or a family member and want to exchange a few files quickly. This “How To” you will be able to “host” your files temporarily and your folders on your GNU / Linux using Python, and you can access via browser from any device connected to the LAN and WLAN.

WHAT IS PYTHON?

Python is a high-level programming language interpreted, object-oriented and extensible. It is a multi-paradigm language variables are not typed, which allows Python to be versatile, fast and efficient. Precisely because of these characteristics, it proves useful to scripting.

DISTRO GNU / LINUX AND PYTHON

Our goal is to have access to a Linux device file via browser from any machine connected via LAN cable (LAN) or wireless (WLAN).
But how?
What we need is a small server to boot from the terminal. The SimpleHTTPServer, this is the script name in the directory we will use

/ Usr / lib / pythonx.y /

is available in all systems that have installed Python version 2.5 or higher.
Given some element of theory, let’s practice!

LET’S PRACTICE!

We want to share the folder “mia_cartella” contained in one of the system.
We initiate the terminal.
Let’s move the folder to be exchanged: Use the command “cd” (change directory).

cd Desktop / mia_cartella

Finally we start the script. The syntax is:

sudo python-m SimpleHTTPServer 80

where 80 is the port on which to listen.
For more ports of 1024 can omit “sudo”.
This is what will appear: The server starts at localhost on port choice.
To end the session just press Ctrl + C

Now just find the IP address of the pc to share the folder with one of the many methods, I suggest sites like http://www.ip-adress.com/ .
Point your Web browser connected to the device (W) LAN from which you access

http://ipaddress:port/

proceeds with the IP address instead of “ipaddress” and the port you chose for the connection instead of “port”. The browser will display a tree structure, such as image, with the contents of the folder from which you started the script.

 

Warning! The script is recursive, so anyone can access it, can also display the subfolders.


0 comments:

Post a Comment