Added switching of effects via the web interface.
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Some checks reported errors
continuous-integration/drone/push Build encountered an error
This commit is contained in:
parent
bbdb46c04d
commit
efa9a73cae
@ -155,11 +155,30 @@ void http_server_setup() {
|
||||
for (int i=0; i<effects_size; i++) {
|
||||
message += "<tr><td>";
|
||||
message += effects[i].name;
|
||||
message += "</td></tr>";
|
||||
message += "</td><td><form method='post' action='/effects'><input type='hidden' name='name' value='";
|
||||
message += effects[i].name;
|
||||
message += "'><input type='hidden' name='redir' value='1'><input type='submit' value='Select'></form></td></tr>";
|
||||
}
|
||||
message += "</table></body></html>";
|
||||
http_server.send(200, "text/html", message);
|
||||
});
|
||||
http_server.on("/effects", HTTP_POST, [&]() {
|
||||
if (!http_server.hasArg("name")) {
|
||||
http_server.send(400, "text/plain", "Missing argument 'name'.");
|
||||
return;
|
||||
}
|
||||
String name = http_server.arg("name");
|
||||
if (change_current_effect(name)) {
|
||||
if (http_server.hasArg("redir")) {
|
||||
http_server.sendHeader("Location", "/effects");
|
||||
http_server.send(301);
|
||||
} else {
|
||||
http_server.send(200, "text/plain", "OK");
|
||||
}
|
||||
} else {
|
||||
http_server.send(404, "text/plain", "Effect not found.");
|
||||
}
|
||||
});
|
||||
http_server.on("/delete", HTTP_GET, [&]() {
|
||||
LOGln("HTTP * GET /delete");
|
||||
if (http_server.args()==0) {
|
||||
|
Loading…
Reference in New Issue
Block a user