Chris Mendez in NodeJS, Javascript, For Developers

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 + '/');