What is nodejs

Node.js is an open source server framework

Node.js is free

Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)

Node.js uses JavaScript on the server

Exmaple: create http server

Create 1 file example.js and save C:\example.js

 

//use module http

var http = require('http');

http.createServer(function (req, res) {

    res.writeHead(200, {'Content-Type': 'text/plain'});

    res.end('Hello World!');

}).listen(8080);

 

Run program with cmd  example.js

 

C:\Nodejs>node example.js

 

Go browser : http://localhost:8080/

 

Hello World!