Created
February 9, 2021 02:34
-
-
Save normandmickey/518219047cdb836d65dfcb1659229900 to your computer and use it in GitHub Desktop.
ESP32 Async Web Server for LNBits - LNURLp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "WiFi.h" | |
#include "ESPAsyncWebServer.h" | |
const char* ssid = "SSID"; | |
const char* password = "PASSWORD"; | |
AsyncWebServer server(80); | |
void setup() { | |
Serial.begin(115200); | |
WiFi.begin(ssid, password); | |
while (WiFi.status() != WL_CONNECTED) { | |
delay(1000); | |
Serial.println("Connecting to WiFi.."); | |
} | |
Serial.println(WiFi.localIP()); | |
server.on( | |
"/post", | |
HTTP_POST, | |
[](AsyncWebServerRequest * request){}, | |
NULL, | |
[](AsyncWebServerRequest * request, uint8_t *data, size_t len, size_t index, size_t total) { | |
for (size_t i = 0; i < len; i++) { | |
Serial.write(data[i]); | |
} | |
Serial.println(); | |
pinMode(2, OUTPUT); | |
digitalWrite(2, HIGH); | |
delay(500); | |
digitalWrite(2, LOW); | |
request->send(200); | |
}); | |
server.begin(); | |
} | |
void loop() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment