Wednesday, 2 October 2019

Create a Server for Node JS Programs

Hi All,

Use this code


----------------------------------------------
1. Create server.js

var http=require("http")
var server=http.createServer(function(request,response)
{
    response.writeHead(200,{'Conent-Type':'text/plain'});
    response.end('Hello World\n');
})

server.listen(8081);
console.log('Server running at http://127.0.0.1:8081');


2. Go to Terminal in VS code and write this code

D:\HUPNode>node server.js

3. You will get the output

Server running at http://127.0.0.1:8081

4. Go to browser and type

 http://127.0.0.1:8081

You will get the output as


No comments:

Post a Comment