#include <WiFi.h>
WiFiServer server(9080);
char lineBuf[80];
int charCount = 0;
void setup() {
  Serial.begin(9600) ;
  Serial.print("Connecting");
  WiFi.begin("Wokwi-GUEST","",6);

  
  while (WiFi.status() != WL_CONNECTED){
    
    delay(100);
    Serial.print(".");

  }


  Serial.println(" Connected!");

}

void loop() {
  WiFiClient client = server.available(); // прослушка входящих клиентов
  if (client) {
    Serial.println("New client");
    memset(lineBuf, 0, sizeof(lineBuf));
    charCount = 0;
    // HTTP-запрос заканчивается пустой строкой
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      client.println("HTTP/1.1 200 OK");
      client.println("Content-Type: text/html");
      client.println("Connection: close");
      client.println();
	  
      // формируем веб-страницу
      String webPage = "<!DOCTYPE HTML>";
      webPage += "<html>";
      webPage += "<head>";
      webPage += "<meta name=\"viewport\" content=\"width=device-width,";
      webPage += "initial-scale=1\">";
      webPage += "</head>";
      webPage += "<body>";
      webPage += "<h1>ESP32 - Web Server</h1>";
      webPage += "<p>AnalogPin 34 = ";
      webPage +=    analogRead(34);
      webPage += "</p>";
      webPage += "<p>AnalogPin 36 = ";
      webPage +=    analogRead(36);
      webPage += "</p>";
      webPage += "<p>AnalogPin 39 = ";
      webPage +=    analogRead(39);
      webPage += "</p>";
      webPage += "</body></html>";
      client.println(webPage);
      break;
    }
    // Даём веб-браузеру время для получения данных
    delay(1);
    // Закрываем соединение
    client.stop();
    Serial.println("client disconnected");
  }
}