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 (format compact, Wi-Fi 2,4/5 GHz, alimentation USB-C 5 V/2,5 A), 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 3 Model A+ (compact format, BCM2837B0, 5 GHz Wi-Fi + Bluetooth, a single USB port, 5 V/700 mA power, 40-pin GPIO). 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 (or bash). Raspberry Pi OS ships gpiozero; otherwise sudo apt install python3-gpiozero. Mind the 700 mA power budget for USB peripherals.
Variants
Radio buttons for several GPIOs; systemd unit as a service; add flask-login before any network exposure. Compact board to cool; USB-C 5 V/2.5 A; a single USB port, add a hub if needed.
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)