#include const char* ssid = "tksteti"; const char* password = "ProsimTeNevim"; const char* deviceName = "ESP-VasePrijmeni"; WiFiServer server(80); void setup() { Serial.begin(115200); //nastaveni Serioveho monitoru delay(10); WiFi.setHostname(deviceName); Serial.println(); Serial.print("Pripojuji se k WiFi: "); Serial.println(); WiFi.begin(ssid,password); //začátek připojování while(WiFi.status() != WL_CONNECTED) { //připojování delay(500); Serial.print("."); } Serial.println(); Serial.println("WiFi připojeno"); // po připojení Serial.print("IP adresa: "); Serial.println(WiFi.localIP()); //zobrazení IP adresy Serial.print("Hostname: "); Serial.println(WiFi.getHostname()); //spusteni serveru server.begin(); } void loop(){ WiFiClient client = server.available(); if(client){ Serial.println("Novy klient pripojen"); String currentLine = ""; while(client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); if (c == '\n'){ if(currentLine.length() == 0) { client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); //odelení hlavičky a html client.println(""); client.println(""); client.println("Hello World"); client.println(""); client.println("

Hello World from ESP32

"); client.println(""); client.println(""); break; } else { currentLine = ""; } } else if (c != '\r'){ currentLine += c; } } } delay(1); client.stop(); Serial.println("Klient odpojen"); } }