My Introduciton to Nodejs
Introduction
Getting started with Nodes.js
Open up the terminal and run the commands to see following results. Make sure to
Pretty simple and not much to show for but this is an introduction with NodeJs as I explore the concepts behind it all. One thing I have been reading is the api docs provided by nodejs itself and seeing what I can do since this article doesn't stray far from the book but does serve as a good starting point.
Much of the material here is based on the chapter 8 in the book: Programming in HTML5 with Javascript and CSS3 and the Nodes.js site.
Getting started with Nodes.js
- "Nodes.js is built on the Google Chrome Javascript runtime"
- "The Platform implements an event-driven, non-blocking I/O model and is lightweight and efficient."
- "data-intensive,real-time applications that run across distributed devices."
- "executes your Javascript by using Google's V8 virtual machine"
Download Nodes.js and install, need to accept the licensing agreements.
HelloWorld.js
var http= require('http') //"http module is a core built-in, low-level module highly optimized."
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type':'text/plain'});
response.end('Hello World from Nodes.js!\n');
console.log('Handled request');
}).listen(8080, 'localhost');
console.log('Server running at http://localhost:8080/');
I simply created the file in my user home folder and ran the command Nodes with the file as an argument.
The Handled request is me hitting the page |
My Results |