Add firmware update button and update endpoint
This commit is contained in:
@@ -272,7 +272,7 @@
|
|||||||
<div class="button-row">
|
<div class="button-row">
|
||||||
<!-- <button onclick="fetch('/tare')">Tank Full</button> -->
|
<!-- <button onclick="fetch('/tare')">Tank Full</button> -->
|
||||||
<button onclick="tankFullProtected()">Tank Full</button>
|
<button onclick="tankFullProtected()">Tank Full</button>
|
||||||
<button onclick="fetch('/calibrate')">Calibrate</button>
|
<button onclick="fetch('/update')">Firmware</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
20
webserver.py
20
webserver.py
@@ -2,6 +2,7 @@ import json
|
|||||||
import gc
|
import gc
|
||||||
import time
|
import time
|
||||||
import uasyncio as asyncio
|
import uasyncio as asyncio
|
||||||
|
#import update
|
||||||
|
|
||||||
# Import config value
|
# Import config value
|
||||||
from config import TANK_CAPACITY_L, VERSION
|
from config import TANK_CAPACITY_L, VERSION
|
||||||
@@ -68,6 +69,25 @@ class WebServer:
|
|||||||
json.dumps({"ok": True}).encode()
|
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) ----------
|
# ---------- JAVASCRIPT (CONFIG INJECTED) ----------
|
||||||
elif path == "/app.js":
|
elif path == "/app.js":
|
||||||
with open("/html/app.js") as f:
|
with open("/html/app.js") as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user