=### Client Wifi / Server HTTP
#include <WiFi.h>
#include <WebServer.h>
//#include <ESPmDNS.h>
const char *ssid = "Your SSID";
const char *password = "P4sswOrd";
WebServer server(80);
void handleRoot() {
String html = "<!DOCTYPE html>";
html += "<html>\n";
html += "<head>\n";
html += "<title>Server ESP32</title>\n";
html += "</head>\n";
html += "<body>\n";
html += "<h1>Hello world</h1>\n";
html += "</body>\n";
html += "</html>";
server.send(200, "text/html", html);
}
void setup(void) {
Serial.begin(115200);
while (!Serial) continue;
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) delay(500);
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
//if (MDNS.begin("esp32")) {
// Serial.println("MDNS responder started");
//}
server.on("/", handleRoot);
server.onNotFound([]() {
server.send(404, "text/plain", "Not Found");
});
server.begin();
Serial.println("HTTP server started");
}
void loop(void) {
server.handleClient();
}