package com.kodedu.tryjshell.nano;

import com.kodedu.tryjshell.websocket.TerminalSocket;
import fi.iki.elonen.NanoHTTPD;
import fi.iki.elonen.NanoWSD;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

public class NanoApp extends NanoWSD {

    public static void main(String[] args) throws IOException {
        new NanoApp("0.0.0.0", 8080).start(5 * 60 * 1000, false);
        System.out.println("\nRunning! Point your browsers to http://localhost:8080/ \n");
    }

    public NanoApp(String hostname, int port) {
        super(hostname, port);
    }

    @Override
    protected WebSocket openWebSocket(IHTTPSession handshake) {
        return new TerminalSocket(this, handshake);
    }

    @Override
    protected Response serveHttp(IHTTPSession session) {
        BufferedInputStream fis = null;
        String contentType = null;
        try {
//            Path root = Paths.get("C:\\Users\\usta\\tryjshell\\src\\main\\resources\\public");

            String uri = session.getUri();

            if (uri.length() == 1) {
                uri = "/index.html";
            }

            InputStream inputStream = NanoApp.class.getResourceAsStream("/public" + uri);

//            Path resolve = root.resolve(uri);
            contentType = Files.probeContentType(Paths.get(uri));
            fis = new BufferedInputStream(inputStream);
        } catch (Exception e) {
//            e.printStackTrace();
            return NanoHTTPD.newFixedLengthResponse("No Response");
        }

        return NanoHTTPD.newChunkedResponse(Response.Status.OK, contentType, fis);
    }

}

@@ -150,44 +150,8 @@
 D;%0A%0A
-import java.io.BufferedInputStream;%0A
 impo
@@ -174,16 +174,16 @@
 eption;%0A
+
 import j
@@ -825,48 +825,8 @@
 ) %7B%0A
-        BufferedInputStream fis = null;%0A
     
@@ -1306,16 +1306,17 @@
 (uri));%0A
+%0A
         
@@ -1323,27 +1323,82 @@
     
-fis = new BufferedI
+return NanoHTTPD.newFixedLengthResponse(Response.Status.OK, contentType, i
 nput
@@ -1403,17 +1403,18 @@
 utStream
-(
+, 
 inputStr
@@ -1416,16 +1416,28 @@
 utStream
+.available()
 );%0A     
@@ -1581,91 +1581,8 @@
  %7D%0A%0A
-        return NanoHTTPD.newChunkedResponse(Response.Status.OK, contentType, fis);%0A
     

Use fixed response