Now that the node is installed, we can create a simple Hello World application. Here is the code for creating this:
var http = require("http") http.createServer(function (request, response) {// Send the HTTP header// HTTP Status: 200 : OK// Content Type: text/plainresponse.writeHead(200, {'Content-Type': 'text/plain'})// Send the response body as "Hello World" response.end('Hello World\n')}).listen(3000)// Console will print the message console.log('Server running')
Feel free to copy this into a file. Alternatively, if you want to save time, download this from GitHub:
[ec2-user@ip-172-31-22-52 ~]$ wget https://raw.githubusercontent.com/yogeshraheja/Effective-DevOps-with-AWS/master/Chapter02/helloworld.js ...