const fs = require("fs");

console.log("Start");
fs.readFile("index.html", 'utf8', function(err, data){
    if(err) {
        console.log("Error :(");
        console.log(err);
    } else {
        console.log("File Read Successfully!");
        console.log(data);
    }
});

console.log("Middle");

// simulate a delayed operation based on the specified number of seconds
function longRunningOperation(callback, delay) {
    setTimeout(callback, delay);
}

function webRequest(request) {
    console.log('starting a long operation for request:', request.id);
    longRunningOperation(function () {
        console.log('ending a long operation for request:', request.id);
    }, request.delay);
}

// simulate a web request
webRequest({ id: 1, delay: 3000});

// simulate a second web request
webRequest({ id: 2, delay: 2000});

console.log("End");