Add firmware update button and update endpoint
This commit is contained in:
20
webserver.py
20
webserver.py
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user