Thursday, 25 August 2016

Simple Server Cretation in Node.js


Some Simple Steps to create Server in Node.js . Required Software are

#Any IDE that will support Node.js plugin
# Download All modules from npm  simple command like

 npm install java // responsible to install java module


Programme

/** * Created by Anand Dwivedi on 8/26/2016. */
    var server=require('http');//Download http module

    server.createServer(createServer).listen(1337);// Server Port Number

    function createServer(req, res){
        res.writeHead(200, {'Content-Type': 'text/plain'});

        res.end('Hey there is Some Request on Server'); //Message display to browser
 }




Once programme runs sucessfully open any browser  then type URL :
  http://localhost:1337/
it will print  Hey there is Some Request on Server


Thanks 


No comments:

Post a Comment