Updates for web server
This commit is contained in:
1 parent
c4adc10a35
commit
fdb214ec55
2 files changed
+82
-5
No files matched your search
@@ -87,11 +87,81 @@ def start_http_server():
|
||||
</html>"""
|
||||
else:
|
||||
# Serve the setup page for any other request
|
||||
try:
|
||||
with open("portal.html") as f:
|
||||
response_body = f.read()
|
||||
except:
|
||||
response_body = "<h1>Setup Page Not Found</h1><p>Please upload portal.html</p>"
|
||||
# Build list of stations
|
||||
html_list = ''
|
||||
for station, dict in stations.items(): # loop through all stations
|
||||
html_list += f'<option value={station}>{stations[station]["name"]}</option>'
|
||||
|
||||
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 = (
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
|
||||
Reference in new issue
Block a user