forked from fmueller/esp8266-led-marquee-sign-controller
Improve webserver
This commit is contained in:
parent
32ba413380
commit
09e8e75edc
@ -28,11 +28,6 @@ namespace {
|
||||
<input type="text" name="text">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="bright">Bright mode</label>
|
||||
<input type="checkbox" name="bright">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button>Send</button>
|
||||
</div>
|
||||
@ -45,7 +40,14 @@ namespace {
|
||||
}
|
||||
|
||||
void handleFormSend() {
|
||||
sendTextToSign("HELLO FORM");
|
||||
String text = webServer.arg("text");
|
||||
|
||||
if (text.isEmpty()) {
|
||||
webServer.send(404, "text/plain", "empty text");
|
||||
return;
|
||||
}
|
||||
|
||||
sendTextToSign(text);
|
||||
|
||||
// redirect back to root page
|
||||
webServer.sendHeader("Location", "/");
|
||||
@ -54,7 +56,14 @@ namespace {
|
||||
|
||||
// RESTful API endpoint -- returns a proper status code rather than a redirect
|
||||
void handleApiSend() {
|
||||
sendTextToSign("HELLO API");
|
||||
String text = webServer.arg("text");
|
||||
|
||||
if (text.isEmpty()) {
|
||||
webServer.send(404, "text/plain", "empty text");
|
||||
return;
|
||||
}
|
||||
|
||||
sendTextToSign(text);
|
||||
webServer.send(200, "text/plain", "ok");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user