const http = require("http");
const url = require("url");

const PORT = 3000;

function requestListener(request, response) {
    console.log("URL: " + request.url);

    let q = url.parse(request.url, true);
    let qdata = q.query;        // returns an object: { year: 2022, month: 'october' }
    for (x in qdata) {
        console.log(x + ": " + qdata[x]);   // year: 2022 and month: october
    }

    response.end();  // an empty response sent back
}
    
http.createServer(requestListener).listen(PORT);
console.log(`Server running at http://localhost:${PORT}`);
