#pragma once #include "util.h" static ESP8266WebServer webServer(80); // use an anonymous namespace for the module's "private" methods // this prevents the methods from ending up in the global namespace namespace { void handleNotFound() { webServer.send(404, "text/plain", "urm... nope"); } void handleIndex() { String htmlText = R"( LED Marquee Sign Controller

LED Marquee Sign Controller

)"; webServer.send(200, "text/html", htmlText); } void handleFormSend() { sendTextToSign("HELLO FORM"); // redirect back to root page webServer.sendHeader("Location", "/"); webServer.send(303); } // RESTful API endpoint -- returns a proper status code rather than a redirect void handleApiSend() { sendTextToSign("HELLO API"); webServer.send(200, "text/plain", "ok"); } } void configureWebServer() { webServer.onNotFound(handleNotFound); webServer.on("/", HTTPMethod::HTTP_GET, handleIndex); webServer.on("/", HTTPMethod::HTTP_POST, handleFormSend); webServer.on("/send", HTTPMethod::HTTP_POST, handleApiSend); }