SPIFFS on ESP8266

Objective is to serve html pages that are store on SPIFFS

#include <WebSocketsServer.h>
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <FS.h>

const char* wifi_password = "";
const char* wifi_ssid = "ZogZog";
const int wifi_channel=1;
const boolean wifi_hidden=false;

const int port_webserver= 80;
const int port_websocket= 81;

const int LED1=14;
const int LED2=12;
const int LED3=13;

const char LED1ON[] = "led1on";
const char LED1OFF[] = "led1off";
const char LED2ON[] = "led2on";
const char LED2OFF[] = "led2off";
const char LED3ON[] = "led3on";
const char LED3OFF[] = "led3off";

IPAddress local_IP(192,168,4,1);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);

WebSocketsServer webSocket = WebSocketsServer(port_websocket);

ESP8266WebServer server(port_webserver);

void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {

    switch(type) {
      
        case WStype_DISCONNECTED:
            Serial.println("Client disconnnected !"+ num);
            break;
            
        case WStype_CONNECTED:
            {
                IPAddress ip = webSocket.remoteIP(num);
                Serial.println("Websocket client connnected !");        
                // send message to client
                webSocket.sendTXT(num, "Connected");                
            }
            break;
            
        case WStype_TEXT:

            if (strcmp(LED1ON, (const char *)payload) == 0) {
              digitalWrite(LED1,1);
            }
            
            else if (strcmp(LED1OFF, (const char *)payload) == 0) {
              digitalWrite(LED1,0);
            }

            else if (strcmp(LED2ON, (const char *)payload) == 0) {
              digitalWrite(LED2,1);
            }
            
            else if (strcmp(LED2OFF, (const char *)payload) == 0) {
              digitalWrite(LED2,0);
            }

            else if (strcmp(LED3ON, (const char *)payload) == 0) {
              digitalWrite(LED3,1);
            }
            
            else if (strcmp(LED3OFF, (const char *)payload) == 0) {
              digitalWrite(LED3,0);
            }
            // send message to client
             webSocket.sendTXT(num, payload);

            // send data to all connected clients
             webSocket.broadcastTXT("Receiving command");
            break;
            
        case WStype_BIN:
            Serial.printf("[%u] get binary length: %u\n", num, length);
            hexdump(payload, length);
            // webSocket.sendBIN(num, payload, length);
            break;
    }

}

void handleNotFound(){
  server.send(404, "text/plain", "404: Not found"); // Send HTTP status 404 (Not Found) when there's no handler for the URI in the request
}

void handleRoot(){
  server.sendHeader("Content-Security-Policy", "script-src 'unsafe-inline';");
  server.send(200,"text/html",INDEX_HTML);
}

void setup() {
  pinMode(LED1, OUTPUT);
  pinMode(LED2, OUTPUT);
  pinMode(LED3, OUTPUT);
  
  Serial.begin(115200);
  Serial.flush();
  Serial.println();
  WiFi.mode(WIFI_AP);
  Serial.print("Setting soft-AP configuration ... ");
  Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Ready" : "Failed!");

  Serial.print("Setting soft-AP ... ");
  Serial.println(WiFi.softAP(wifi_ssid,wifi_password,wifi_channel,wifi_hidden,4) ? "Ready" : "Failed!");

  Serial.print("Soft-AP IP address = ");
  Serial.println(WiFi.softAPIP());

  delay(100);  

  server.begin();

  SPIFFS.begin();
  Serial.println("Starting file System");
 
  webSocket.begin();
  webSocket.onEvent(webSocketEvent);

  server.serveStatic("/", SPIFFS, "/index.html","Content-Security-Policy script-src;" );
  server.onNotFound(handleNotFound);        // When a client requests an unknown URI (i.e. something other than "/"), call function "handleNotFound"  

}

void loop() {
  server.handleClient();
  webSocket.loop();
}
<html>
  <head>
    <script>
        var connection = new WebSocket('ws://192.168.4.1:81/', ['arduino']);
        connection.onopen = function () {  
          connection.send('Connect ' + new Date());
                                  var e = document.getElementById('cstate');
                                  e.innerHTML = 'Connected !';
                                  e.style.color = 'green'         
        };

        connection.onerror = function (error) {
          console.log('WebSocket Error ', error);
                                  var e = document.getElementById('cstate');
                                  e.innerHTML = 'Disconnected !';
                                  e.style.color = 'red'
        };

        connection.onmessage = function (e) {  
          console.log('Server: ', e.data);
        };

        function buttonclick(e) {
          connection.send(e.id);
        }
    </script>
  </head>
  <body>
    <div id='cstate'><b>Disconnected !</b></div>
    <br />
    <br/>
    <br/>LED 1
    <button id='led1on'  type='button' onclick='buttonclick(this);'>On</button>
    <button id='led1off' type='button' onclick='buttonclick(this);'>Off</button>
                <br/>LED 2
                <button id='led2on'  type='button' onclick='buttonclick(this);'>On</button>
                <button id='led2off' type='button' onclick='buttonclick(this);'>Off</button>
                <br/>LED 3
                <button id='led3on'  type='button' onclick='buttonclick(this);'>On</button>
                <button id='led3off' type='button' onclick='buttonclick(this);'>Off</button>
  </body>
</html>