PDA

View Full Version : node.js does not work



hamd
09-22-2011, 07:13 AM
Hello everyone,
I installed successfully node.js and I tried these examples:
-----------------------------------------------
>2+2
4
-----------------------------------------------
>function add(a,b){ return (a+b); }
>add(20,20)
40
-----------------------------------------------
It worked however, this :
var sys = require('sys'),
http = require('http');
http.createServer(function (req, res) {
setTimeout(function () {
res.sendHeader(200, {'Content-Type': 'text/plain'});
res.sendBody('Hello World');
res.finish();
}, 2000);
}).listen(40740);
sys.puts('Server running at http://127.0.0.1:40740/');

Any idea please? Thanks