How to setup a File server in minutes using Python
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 Python. In other words, you can access your system hard disk’s entire contents via a web browser. I am not going to install any other software or do any complex configuration. Anyone, even the novice user, can do this within a minute or two. Follow me.
You know how to install Python. It is available in the default repositories of almost all modern Linux operating systems.
On Debian/Ubuntu and its derivatives, run the following command from the Terminal:
sudo apt-get install python
sudo yum install python
sudo dnf install python
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 7000
Serving HTTP on 0.0.0.0 port 8000 ...
To stop the file server, just press CTRL+C.
To find Python version, run the following command:
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
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.
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.