11 Aralık 2016 Pazar

Creating a Server by using Node.js

I will present in detail about Node.js. This page can be seen as a draft for creating a server task by using Node.js.

You can find the code below.

server.js file :
var http = require('http');
var host = '127.0.0.1';
var port = '1330';
var server= http.createServer(function(request,response) {
console.log("Coming request: "+request.url);
response.writeHead(200 , {'Content-type' : 'text/plain'});
response.end('Hello World!');
});

server.listen(port,host,function(){
  console.log('Listening port'+ ':' +host+':'+port);
});

You can start the server by typing "node server.js" into the command shell.



You can use Chrome's Postman extension as client that posts requests.


Hiç yorum yok:

Yorum Gönder