How to Setup A Basic File server Using simpleHTTPserver

Today, I show you a cool trick that I came across. It is how to turn your desktop system into a local file server in minutes using simpleHTTPserver. In other words, you can access your system hard disk’s entire contents via a web browser. Anyone, even a novice user, can do this within a minute. simpleHTTPserver is a python module that can be used to setup a file server or serve a directory instantly in LAN. Anyone in the local area network can instantly access the folder or files from your system.

This brief tutorial describes how to setup a basic file server in minutes using simpleHTTPserver in Linux. This steps should work on any operating systems that supports python.

Install Python

You know how to install Python. It is available in the default repositories of almost all modern Linux operating systems.

On Arch Linux and its derivatives:

sudo pacman -S python

On Debian/Ubuntu and its derivatives, run the following command from the Terminal:

sudo apt-get install python

On RHEL/CentOS:

sudo yum install python

For Fedora:

sudo dnf install python

On SUSE/openSUSE:

sudo zypper in python

After installing Python, you need to do one more thing. Just run the following command from your Terminal to start the file server:

python -m SimpleHTTPServer

For python 3.0 and above versions, run:

python -m  http.server 8000

Sample output would be:

Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ..

To stop the file server, just press CTRL+C.

To find Python version, run the following command:

python -V

Sample output:

Python 2.7.10

That’s it. File server is ready. Open the web browser and point it to http://IP-Address:8000

In case the port 8000 is blocked in your firewall, you have to open it.

For example, on RHEL/CentOS/Fedora, open port 8000 as shown below.

firewall-cmd --permanent --add-port=8000/tcp
firewall-cmd --reload

On Debian, Ubuntu you can allow the port as shown below.

sudo ufw allow 8000

Here it is how my local server’s contents looks in my browser.

Now, anyone can access your File server and it’s contents. Just set the permissions to your files and folders of your choice. Now, you can browse the contents from any local or remote systems as the way you do in any file server or website.

Disclaimer:

This is not full-fledged and secured file server. Python simply allow you to access your desktop/server contents via a web browser. This method is not recommended for production use. Use it within closed networks and home. Also, don’t forget to set proper permissions to avoid data loss and misuse.

Cheers!

You may also like...