From d9d92e1310b63a55d8ce89408a7ddbc39a6f582c Mon Sep 17 00:00:00 2001 From: Joe Tretter Date: Fri, 24 Jun 2022 15:46:56 -0500 Subject: [PATCH] add status API --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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);