First Application with Node.js
Creating a Node.js Application
Step 1: Import the required modules
var http = require("http");
Step 2: Create the Server
var http = require("http");
http.createServer(function (request, response) {
/*
Send HTTP Header
HTTP Status: 200 : OK
Content Type: text/plain
*/
response.writeHead(200, {'Content-Type': 'text/plain'});
/*
Set Response Body to "Hello World"
*/
response.end("Hello World\n");
}).listen(8081);
console.log("Server running at http://127.0.0.1:8081");Step 3: Test the Server

Last updated