I like the PC version that runs off a USB memory stick in an old laptop.
sudo busybox httpd -p 0.0.0.0:8086 -h /home/pi/www
I changed the hostname of my raspberry pi to patrickpi
http://patrickpi:8086/
http://patrickpi.local:8086/
The Broadband router, I have has a useful frontpage
http://192.168.1.254/
cron -A super-simple way to run scripts on boot
https://learn.pimoroni.com/article/running-scripts-at-boot
crontab -e Add:
@reboot python /home/pi/Pimoroni/blinkt/examples/rainbow.py &
A way to start a web server
A Way to start a web server when the RPi boots:-
A way to start a web server using rc.local
# Howevery this already has two web servers you can use. # * busybox httpd # * python -m httpd.server 8080 & # # To get it to boot on power up set up /etc/rc.local # # scp pi@patrickpi:/etc/rc.local rc.local.txt # #================================================= #!/bin/sh -e # owned by root # chmod 755 /etc/rc.local #!/usr/bin/ env python # # You could start a webserver using:- # python -m http.server 8080 &
# log last boot time for debug purposes date > /home/pi/rclocal.txt
# log env to file for debug purposes /usr/bin/env >> /home/pi/rclocal.txt
python dhr.py
sudo nano /lib/systemd/system/dhr.service
sudo systemctl start dhr.service
sudo systemctl stop dhr.service
sudo systemctl enable dhr.service
sudo systemctl disable dhr.service
sudo nano /lib/systemd/system/dhr.service
[Unit] Description=dhrPythonScript. After=network.target
[Service] ExecStart=/usr/bin/python3 /home/pi/dhr.py Restart=always User=pi
[Install] WantedBy=multi-user.target
This will start a webserver. this can be very useful for getting files off the Raspberry Pi.
python -m http.server 8080 --directory /home/pi
sudo nano /home/ip/dhr.py
import http.server import socketserver
PORT = 8080 DIRECTORY = "/home/pi"
class Handler( http.server.SimpleHTTPRequestHandler ): def __init__(self, *args, **kwargs): super().__init__(*args, directory=DIRECTORY, **kwargs)
# Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler ) as httpd: print("serving at port", PORT) httpd.serve_forever()