diff --git a/src/main.cpp b/src/main.cpp index 845fef0..9409b06 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -199,6 +199,11 @@ void setup(void) { file.close(); server.send(200, "text/html", thePage); }); + server.on("/status", HTTP_GET, []() { + server.sendHeader("Connection", "close"); + boolean isOpen=digitalRead(buttonPin)==HIGH; + server.send(200, "application/json", "{ \"isOpen\": " + String(isOpen?"true":"false") + " }"); + }); server.on("/serverIndex", HTTP_GET, []() { server.sendHeader("Connection", "close"); server.send(200, "text/html", serverIndex);