it's my HTML code
- const char *ssid = "MyESP";
- const char HTML[] PROGMEM = "<script language=\"JavaScript\">function formToJson(form){var pass=form.pass.value;var ssid=form.ssid.value;var jsonFormInfo=JSON.stringify({pass:pass, ssid: ssid});window.alert('OK');}</script> <form onSubmit=\"event.preventDefault(); formToJson(this);\"> <label class=\"label\">Network Name</label> <input type=\"text\" name=\"ssid\"/> <label>Password</label> <input type=\"text\" name=\pass/> <input type=\"submit\" value=\"Submit\"></form>";
- AsyncWebServer server(80);
- void setup() {
- Serial.begin(115200);
- WiFi.softAP(ssid);
- Serial.println();
- Serial.print("IP address: ");
- Serial.println(WiFi.softAPIP());
- server.on("/Cfig", HTTP_GET, [](AsyncWebServerRequest *request) {
- request->send(200, "text/html", HTML);});
- server.begin();
- HTTPClient http;
- http.begin("http://192.168.1.87");
- http.addHeader("Content-Type", "text/plain");
- int httpResponseCode = http.POST("POSTING from ESP32");
- if (httpResponseCode > 0) {
- String response = http.getString();
- Serial.println(httpResponse);
- Serial.println(response); }
- else {Serial.print("Error on sending POST: ");
- Serial.println(httpResponse);}
- http.end();}