Sharing Files Easily With Python

Want to share some files in a folder from your unix OS to others PCs on the same network, without having to install any other library, just Python?

Simple HTTP Server

There is a simple command that lets you create a very basic HTPP server in the current folder, and it’s just one line!

python -m SimpleHTTPServer 8000

This will run a local server using the port 8000 to the current dir(from where you run this command).

Then I’ll you need to do is get your IP and access it in a browser from another PC, ex:
192.168.0.5:8000

And then you just navigate and download the files from the browser, simple as that!

So if I want to share the contents of the folder: /home/my_user/some_folder, just enter this folder,
and run the simpleHTTTPServer in there!



Using an alias

You can even set a alias on your bash_rc(or similar) to make it easier, ex:

alias share_local = 'python -m SimpleHTTPServer 8000'

Then all you’ll have to do is:

share_local

About arruda

Adoro programar, descobrir novas frameworks ágeis e suas diversas aplicações.