public static void main(String[] args) throws IOException {

        ServerSocket server = new ServerSocket(LISTENING_PORT, 1, InetAddress.getByName("127.0.0.1"));
        Socket socket = null;
        BufferedReader input = null;
        PrintWriter output = null;

        while (true) {

            socket = server.accept(); // server waits for a connection from a client
            input = new BufferedReader(new InputStreamReader(socket.getInputStream())); // input stream
            output = new PrintWriter(socket.getOutputStream()); // output stream
            Gson gson = new Gson();
            
            try {
                requestInfo = input.readLine();
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
            if (requestInfo == null) {
                socket.close();
                continue;
            }

            if (requestInfo.startsWith("GET")) {

                System.out.println(requestInfo); //prints the first line of the GET request info  
                getParams(requestInfo);

                if (params.containsKey("year") && params.containsKey("name")) {
                    String year = params.get("year");
                    String name = params.get("name");
                    Compilation compilation = new Compilation(name, year);
                    gson.toJson(compilation.toString());
                    //System.out.println(gson.toString());
                    
                }
                else {
                    sendBadResponse(output, "Request Error: No params in GET method!");
                }
                readRequestInfo(requestInfo, input);

            }
            else if (requestInfo.startsWith("POST")) {

                System.out.println(requestInfo); //prints the first line of the POST request info
                readRequestInfo(requestInfo, input);
            }
            else {
                sendBadResponse(output, "Not a POST or a GET method");
            }

            input.close();
            output.close();
            socket.close();
        }

    }