Node.js brings JavaScript to the server side, and is designed with an event-driven architecture capable of asynchronous I/O.
It’s easy to get started: download Node.js and install it so that it runs from your command line.
Then, create a simple hello_world.js file with these contents:
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.write('Hello World!');
res.end();
}).listen(8080);
Now run your newly created server with node.js:
$ node hello_world.js
and wa-la! go to http://localhost:8080/ in your browser and you will see:
You are running a Node.js server process that can handle HTTP requests!
With Node.js servers, you can:
- parse the URL request
- access server local files: read, create, update, delete, rename
- process events
- upload files
- access SQL or NoSQL databases
- use NPM packages for all kinds of functionality!