web_led.py
A minimal Flask server exposes /on and /off to drive an LED on GPIO17 from any LAN browser. With the board on Wi-Fi (puce I/O RP1, USB-C 5 V/5 A (27 W), deux ports CSI, connecteur JST pour caméra/ventilateur), grab the IP with hostname -I. It listens on 0.0.0.0:8000; never expose the board to the Internet.
Hardware
A Raspberry Pi 5 (quad-core BCM2712 at 2.4 GHz, RP1 I/O chip, 40-pin GPIO, recommended 5 V/5 A USB-C power, two CSI camera ports). LED + 330-ohm resistor, local network (Ethernet, Wi-Fi or USB dongle per model).
Wiring
LED on GPIO17 (pin 11) with resistor to GND. Nothing else but networking.
How it works
Each URL is a Flask route: the view calls led.on/off then re-renders with led.value. The single-thread server is fine for a demo.
Running it
Copy the script to the board (scp), then run it with python3. On Bookworm, gpiozero 2.x drives the pins through the RP1 chip; keep gpiozero and python3-rpi.gpio updated (sudo apt full-upgrade). A 5 V/5 A supply is advised.
Variants
Radio buttons for several GPIOs; systemd unit as a service; add flask-login before any network exposure. A 27 W (5 V/5 A) supply is recommended; without it USB output is capped at 600 mA total.
web_led.py
# web_led.py — page web locale pour allumer/eteindre une LED (Flask).
# Deps: sudo apt install python3-flask python3-gpiozero
from flask import Flask
from gpiozero import LED
app = Flask(__name__)
led = LED(17)
@app.route("/")
def index():
etat = "allumee" if led.value else "eteinte"
return (f"<h1>LED {etat}</h1>"
'<p><a href="/on">Allumer</a> | <a href="/off">Eteindre</a></p>')
@app.route("/on")
def on():
led.on()
return index()
@app.route("/off")
def off():
led.off()
return index()
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)