Add favicon handler and heartbeat LED blink.

This keeps the UI console clean and makes device status visible.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-02-08 13:51:15 +13:00
parent d907ca37ad
commit 7cd4a91350

View File

@@ -2,6 +2,7 @@ import asyncio
import gc
import json
import machine
from machine import Pin
from microdot import Microdot, send_file
from microdot.websocket import with_websocket
from microdot.session import Session
@@ -23,6 +24,7 @@ from models.espnow import ESPNow
async def main(port=80):
settings = Settings()
print(settings)
print("Starting")
sta = network.WLAN(network.STA_IF)
@@ -72,6 +74,11 @@ async def main(port=80):
"""Serve the settings page."""
return send_file('templates/settings.html')
# Favicon: avoid 404 in browser console (no file needed)
@app.route('/favicon.ico')
def favicon(request):
return '', 204
# Static file route
@app.route("/static/<path:path>")
def static_handler(request, path):
@@ -107,10 +114,20 @@ async def main(port=80):
#wdt = machine.WDT(timeout=10000)
#wdt.feed()
# Initialize heartbeat LED (XIAO ESP32S3 built-in LED on GPIO 21)
led = Pin(21, Pin.OUT)
led_state = False
while True:
gc.collect()
for i in range(60):
#wdt.feed()
# Heartbeat: toggle LED every 500 ms
led.value(not led.value())
await asyncio.sleep_ms(500)
# cleanup before ending the application