Commit 32cde90b authored by Eric Duminil's avatar Eric Duminil
Browse files

Basic webserver commands

parent 6e522d4e
......@@ -22,6 +22,7 @@ namespace web_server {
const char *script_template;
void handleWebServerRoot();
void handlePageNotFound();
void handleWebServerCommand();
#ifdef AMPEL_CSV
void handleDeleteCSV();
......@@ -173,6 +174,7 @@ namespace web_server {
// Web-server
http.on("/", handleWebServerRoot);
http.on("/command", handleWebServerCommand);
#ifdef AMPEL_CSV
http.on("/" + csv_writer::filename, handleWebServerCSV);
http.on("/delete_csv", HTTP_POST, handleDeleteCSV);
......@@ -275,6 +277,15 @@ namespace web_server {
}
#endif
void handleWebServerCommand() {
if (!shouldBeAllowed()) {
return http.requestAuthentication(DIGEST_AUTH);
}
sensor_commands::run(http.arg("send").c_str());
http.sendHeader("Location", "/");
http.send(303);
}
void handlePageNotFound() {
http.send(404, F("text/plain"), F("404: Not found"));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment