Problem in Using SPIFFS in esp8266

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");
}

title of your post doesn't match with the post.
if your problem is creating a response to http request look at Problem in get method of HTML - Project Guidance - Arduino Forum

Did you take a look at the examples that come with the ESP8266 Arduino Core?
There's a FSBrowser example.
Here's another one: https://tttapa.github.io/ESP8266/Chap11 - SPIFFS.html

Pieter

@juraj

No I dont want request
I have a html code and I can upload it on my module successfully

But I dont know how to say to client that go and pick up the file that i say you to open.

I mean that how can i say to client to get the file and run it on browser

The client can't "get" or "pick up" the file. The server has to open the file, and send all contents to the client.

Pieter

Ok

But how can I do this??

Mary7586:
Ok

But how can I do this??

Have you even read reply #2?