so Im following a beginner nodejs course, and everytime I run the code in vs with the command "node app.js", the server works fine and it displays the first log message, which is "server running in port 4000" and its in the main script (app.js). But other logs in other scripts such as myLogs.js, don´t appear, actually no other log written after the "server running in port" line works. The terminal just "freezes" and i cant write anything on it, i have to create a new one to finish the process and etc. Why? The entire app.js code looks like this:
var http = require("http");
var log = require("./modules/myLogs");
var consts = require("./utils/consts");
var server = http.createServer(function(request, response) {
if (request.url === "/") {
response.writeHead(200 ,{"Content-Type" : "text/html"});
response.write("<html><body><p>HOME PAGE</p></body></html>");
response.end();
}
else if (request.url === "/exit") {
response.writeHead(200 ,{"Content-Type" : "text/html"});
response.write("<html><body><p>REQUEST DECLINED</p></body></html>");
response.end();
}
else if(request.url === "/info") {
var result = log.info(request.url);
response.writeHead(200 ,{"Content-Type" : "text/html"});
response.write(result);
response.end();
}
else if (request.url === "/error") {
var result = log.error(request.url);
response.writeHead(200 ,{"Content-Type" : "text/html"});
response.write(result);
response.end();
}
else {
response.writeHead(404, {"Content-Type" : "text/html"})
response.write("<html><body><p>PAGE NOT FOUND</p></body></html>")
response.end();
}
})
server.listen(4000);
console.log("¡Server running on port 4000!");