Add firmware update button and update endpoint

This commit is contained in:
2026-06-17 11:41:56 +02:00
parent 5520a9f4e9
commit 3e1ad11a67
2 changed files with 21 additions and 1 deletions

View File

@@ -272,7 +272,7 @@
<div class="button-row">
<!-- <button onclick="fetch('/tare')">Tank Full</button> -->
<button onclick="tankFullProtected()">Tank Full</button>
<button onclick="fetch('/calibrate')">Calibrate</button>
<button onclick="fetch('/update')">Firmware</button>
</div>
</div>

View File

@@ -2,6 +2,7 @@ import json
import gc
import time
import uasyncio as asyncio
#import update
# Import config value
from config import TANK_CAPACITY_L, VERSION
@@ -68,6 +69,25 @@ class WebServer:
json.dumps({"ok": True}).encode()
)
# ---------- UPDATE ----------
elif path == "/update":
writer.write(
b"HTTP/1.1 200 OK\r\n"
b"Content-Type: application/json\r\n\r\n" +
json.dumps({
"ok": True,
"message": "Starting update"
}).encode()
)
await writer.drain()
import update
# # ---------- JAVASCRIPT ----------
# elif path == "/app.js":
# ---------- JAVASCRIPT (CONFIG INJECTED) ----------
elif path == "/app.js":
with open("/html/app.js") as f: