#include <WiFi.h>
#include <WebServer.h>
const char* ssid = "Wokwi-GUEST";
const char* password = "";
WebServer server(80);
void handleRoot() {
if (!server.authenticate("admin", "password")) {
return server.requestAuthentication();
}
server.send(200, "text/html", "<h1>Welcome to the Secure Area</h1><p>If you see this message, it means you have successfully logged in.</p>");
}
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
server.on("/", handleRoot);
server.begin();
Serial.println("HTTP server started");
}
void loop() {
server.handleClient();
}