Quick sharing of files
This is the easiest and quickest way of making files available in the team. Or set up a HTTP web server the easy way. - SimpleHTTPServer The only prerequisite to follow this guide is that you have Python 3 installed on your system. Python 2 will also work if you still are on two.
This is the easiest and quickest way of making files available in the team. Set up an ad-hoc web server the easy way - SimpleHTTPServer (on Pyhton 3 http.server).
The only prerequisite to follow this guide is that you have Python 3 installed on your system. Python 2 will also work if you still are on two. By default its on port 8000 (ports over 1024 is safer, no need for root privileges)
Usage
If we haw a PC with the address 192.168.1.100 we can browse the directory with any browser by http://192.168.1.100:8000
Go to the firewall and open the port you will use for the HTTP server on your PC/Mac (here 192.168.1.100) the default port is 8000 (here I'm using 3008).
With Python 3 can bind to your PC's/Mac's IP (python3 -m http.server --bind 10.10.1.10 3008). You can change this to anything you want, or omit the --bind options entirely to have Python be hosted on the default IP 0.0.0.0 and port 8000.
Open your terminal in the directory you like to share and (the port is optional) (add an & at the end and the web server stays alive after closing the terminal :
Python 3 is installed on your machine
python3 -m http.server 3008 &
Python 2 is install on your machine
python -m SimpleHTTPServer 3008 &
Installing Python 3 on your machine
Debian based systems (Ubuntu, Pop, Mint ...)
sudo apt install python3
Red Hat based systems (Fedora, Alma ...)
sudo dnf install python3
Arch based systems (Arco, Mandjaro, Garuda ...)
sudo pacman -S python3
macOS Ventura
Python3 is now included with Ventura.
Other use of the SimpleHTTPServer
Add a favicon and a index.html file to the directory to make it a web server.
<!-- #index.html -->
<html>
<header>
<title>CasaUrsus Files</title>
<link rel="shortcut icon" type="image/jpg" href="/img/favicon.ico"/>
<!-- <link rel="icon" type="image/x-icon" href="/img/favicon.ico"> -->
</header>
<body text="purple"><H1>
Hi all!<br> SimpleHTTPServer works fine.
</H1>
<p><a href="https://homeserver.casaursus.net">Visit CasaUrsus</a></p>
<h3>This is a Heading h3</h3>
<p>This is a paragraph.</p>
</body>
</html>
Run http.server as an .service
Create a file and edit it, what you call is it's up to you.
sudo nano /etc/systemd/system/http-simple.service
[Unit]
Description=Daemon that runs Python3 http.server alias Simple HTTP Server
After=network.target # Start daemon when network interfaces available
[Service]
Type=simple
User=1003
Group=1003
WorkingDirectory=/tftpboot
# Run as 8080 as non root (all ports above 1024)
ExecStart=/usr/bin/python3 -m http.server 8080
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl restart http-simple.service
systemctl status http-simple.service
References
SimpleHTTPServer [1]
See the documentation ↩︎