SimpleHTTPServer
Simple HTTP server is a built-in python module that can be used to launch a lightweight server suitable for running basic web applications and lightweight file server. As it is a built-in module, it comes pre-installed on almost all Linux distributions having Python installed by default.
Simple HTTP server serves all the files located in the folder it is run from. Run the following commands in succession to launch a simple HTTP server in the “Downloads” folder located in your home directory (commands below are for Python 3 only).
$ python3 -m http.server
To run the server on a different port, run the following command instead (change port number according to your requirements):
You will see following terminal output on successful launch of the server:
If you click on the URL mentioned in the terminal output shown above, you will be able to see a basic file browser layout in the web browser (also on http://localhost:8000/):
To share files with a different device, you have to use a URL in the “http://ip_address:8000/” format. To find IP address of of your computer where simple HTTP server is running, run the command below:
You will get some output like this:
Enter the IP address obtained above in the URL. The correct URL to access the file server now would be: “http://192.168.0.107:8000/”. You can open this URL in any web browser on any device to download the listed files. Below is a screenshot of this URL opened on an Android device:
To stop the server anytime, press <CTRL+C> while the terminal window is in focus.
HTTP-Server (Node.js)
Http-server is a Node.js module that allows you to run a simple, easy to use and configurable web server. You can use the http-server module to share files from any folder on your system.
To install Node.js on Ubuntu, run the command below:
To install http-server module, run the command below:
To run the http-server from “Downloads” folder in your home directory, run the following two commands in succession:
$ http-server
On successful launch of http-server, you will see some output like this:
Available on:
http://127.0.0.1:8080
http://192.168.0.107:8080
You can now use the second URL listed in the output above to open the file browser in a web browser.
To stop the server anytime, press <CTRL+C> while the terminal window is in focus.
Twistd
Twistd is a simple web server that comes with the “Twisted” python module. It can be used to launch a server that uses http or ftp protocol for sharing files. To install twisted in Ubuntu, run the command below:
To run the twistd from “Downloads” folder in your home directory, run the following two commands in succession:
$ twistd3 -n web --path .
On successful launch of web server, you will get some output in the terminal like this:
You can now use a URL in the “http://ip_address:8080/” format. To see IP address of your system, run the command below:
You will get some output like this:
Enter the IP address obtained above in the URL. The correct URL to access the file server now would be: “http://192.168.0.107:8080/”. You can open this URL in any web browser on any device to download the listed files. Below is a screenshot of this URL opened in Firefox web browser on Ubuntu:
To stop the server anytime, press <CTRL+C> while the terminal window is in focus.
Httpd (Ruby)
Httpd is a lightweight server that comes with the default Ruby package on most Linux distributions. In terms of functionality, it is on par with Python’s simple HTTP server.
To install Ruby on Ubuntu, run the command below:
To run the Ruby httpd from “Downloads” folder in your home directory, run the following two commands in succession:
$ ruby -run -e httpd . -p 8000
On successful launch of web server, you will get some output in the terminal like this:
You can now use a URL in the “http://ip_address:8000/” format. To see IP address of your system, run the command below:
You will get some output like this:
Enter the IP address obtained above in the URL. The correct URL to access the file server now would be: “http://192.168.0.107:8080/”. You can open this URL in any web browser on any device to download the listed files. Below is a screenshot of this URL opened in Firefox web browser on Ubuntu:
To stop the server anytime, press <CTRL+C> while the terminal window is in focus.
Conclusion
These are a few lightweight web server applications that are easy to use and can be used to share files publicly. If you want to share files over a network with higher security and authentication standards, these applications may not be suitable and avoid using them in production.