[Home]Raspsberry Pi

HomePage | RecentChanges | Preferences | My Website home page

Showing revision 4

The Raspberry Pi

https://www.raspberrypi.com/

I like the PC version that runs off a USB memory stick in an old laptop.

Starting a simple Busybox Webserver

https://oldforum.puppylinux.com/viewtopic.php?t=115252

sudo busybox httpd -p 0.0.0.0:8086 -h /home/pi/www

A Way to start a web server when the RPi boots:-

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

A way to start a web server using system.d

 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

Python Web server

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

dhr.py - python web server

 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()


HomePage | RecentChanges | Preferences | My Website home page
This page is read-only | View other revisions | View current revision
Edited February 16, 2025 9:50 am by dougrice.plus.com
Search: