@Override
    public void handle(HttpExchange he) throws IOException {

        String requestedFile = he.getRequestURI().getPath().substring(1);
        File file;

        if (requestedFile.equals("")) {
            file = new File(contentFolder + "index.html");
            contentType = "text/html";
        } else if (requestedFile.equals("/")) {
            file = new File(contentFolder + "index.html");
            contentType = "text/html";
        } else {
            file = new File(contentFolder + requestedFile);
            contentType = getExtension(requestedFile.substring(requestedFile.lastIndexOf(".")));
        }

        if (!file.exists()) {
            response.error(he, 404, response.FILE_NOT_FOUND);
            return;
        }

        byte[] bytesToSend = new byte[(int) file.length()];
        try (FileInputStream input = new FileInputStream(file);) {
            input.read(bytesToSend, 0, bytesToSend.length);
        }

        Headers h = he.getResponseHeaders();
        h.add("Content-Type", contentType);
        h.add("charset", "UTF-8");
        response.send(he, 200, bytesToSend);
    }