Chris Mendez in For Developers, NodeJS, Javascript

Simple NodeJS Server

This is the simplest NodeJS server you can create.

var port = 8080;  
var server = "localhost"  
var http = require('http').createServer( onServerCreatedHandler );  
    http.listen( port, server );

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

console.log('Server running at http://' + server + ':' + port + '/');