Updates for web server

This commit is contained in:
iosullivan committed 2026-10-05 18:11:21 +10:00
1 parent c4adc10a35
commit fdb214ec55
2 files changed
+82 -5

No files matched your search

+75 -5
View File
@@ -87,11 +87,81 @@ def start_http_server():
</html>""" </html>"""
else: else:
# Serve the setup page for any other request # Serve the setup page for any other request
try: # Build list of stations
with open("portal.html") as f: html_list = ''
response_body = f.read() for station, dict in stations.items(): # loop through all stations
except: html_list += f'<option value={station}>{stations[station]["name"]}</option>'
response_body = "<h1>Setup Page Not Found</h1><p>Please upload portal.html</p>"
response_body = """<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Device Setup</title>
<style>
body {
font-family: sans-serif;
padding: 16px;
max-width: 400px;
margin: 0 auto;
}
h2 {
margin-top: 0;
}
label {
display: block;
margin-top: 12px;
font-weight: bold;
}
input, button {
width: 100%;
padding: 10px;
margin-top: 6px;
font-size: 16px;
box-sizing: border-box;
}
button {
margin-top: 20px;
background: #007bff;
color: white;
border: none;
cursor: pointer;
}
button:hover {
background: #0056b3;
}
</style>
</head>
<body>
<h2>Device Setup</h2>
<form method="POST" action="/save">
<label>
Wi-Fi SSID
<input name="SSID" required>
</label>
<label>
Password
<input name="PASS" type="password">
</label>
<label>
CTA API Key
<input name="APIKEY">
</label>
<label>
Left LED Station:
<select name="Station">
{}
</select>
</label>
<button type="submit">Save & Connect</button>
</form>
</body>
</html>""".format(html_list)
response = ( response = (
"HTTP/1.1 200 OK\r\n" "HTTP/1.1 200 OK\r\n"
@@ -56,6 +56,13 @@
<input name="APIKEY"> <input name="APIKEY">
</label> </label>
<label>
Left LED Station
<select name="Station">
<option value="40820">Rosemont</option>
</select>
</label>
<button type="submit">Save & Connect</button> <button type="submit">Save & Connect</button>
</form> </form>
</body> </body>