Hi
I have uploaded my web server code into my ESP8266(NodeMcu) and it successfully uploaded
and I have written some code in sketch to connect to my web server but it cant show my web server
because I dont know how to send data from my file to client.
Here is my code could anyone help me to fix this?
#include <ESP8266WiFi.h>
#include <FS.h>
const char* ssid = "****";
const char* password = "****";
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
server.begin();
Serial.println("Server started");
Serial.println(WiFi.localIP());
SPIFFS.begin();
}
void loop() {
File f = SPIFFS.open("/s.html", "r");
WiFiClient client = server.available();
if (!client) {
return;
}
Serial.println("new client");
while (!client.available()) {
delay(1);
}
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
delay(1);
Serial.println("Client disconnected");
}