how to create a server in Nodejs
how to create a server in Nodejs
1 Answer
First, you need to install Nodejs from official website
then you need to create a new file myServer.js
after that, you need to add this snippet code to the previous file
var http = require('http');
http.createServer(function(req,res){
res.writeHead(200,{'Content-Type': 'text/html'});
res.write("Server Run");
res.end();
}).listen(801);
now you need to run this code in the command line
$ node myServer.js
then you can access your browser at http://localhost:801/
you will see the result Server Run
answer Link