4. HTTP Server Web Application
var http = require("http");
http.createServer(function (req, res) {
console.log(“Your application is running on localhost:9000”);
req.on("end", function () {
res.writeHead(200, { 'ContentType': 'text/plain' });
res.end(‘Welcome!!');
}).listen(9000);
Now, run the node welcome.js on command line/terminal
(command line/terminal should navigate that folder which contains
welcome.js file). This time, you will see in console “Your application
is running on localhost:9000”. When you will open your browser on
localhost:9000, you will see “welcome!!” on your screen.