Node.js http create echo server

Description

Node.js http create echo server

var http = require('http');

var server = http.createServer( function(req, res) {
  res.writeHead(200);//  w  w w . j a  v  a2 s  .  c o m
  req.on('data', function(data) {
    res.write(data);
  });

  req.on('end', function(){
    res.end();
  });
});

server.listen(1337);
console.log('Server started...');



PreviousNext

Related