Hector Correa / http://hectorcorrea.com / @hectorjcorrea
1 http://www.ibm.com/developerworks/opensource/library/os-nodejs/
"Node.js uses an event-driven, non-blocking I/O model
that makes it lightweight and efficient,
perfect for data-intensive real-time applications
that run across distributed devices."
Reference http://nodejs.org
text = readFile("myfile.txt");
console.log(text);
readFile("myfile.txt", function(text) {
console.log(text);
});
console.log("xxx"); // executes immediately
$.ajax({
url: "/js/fakedata.js",
dataType: "json",
success: function(data) {
$("#txtName").val(data.name);
$("#txtCity").val(data.city);
},
error: function(data) {
alert("Oops...something went wrong" + data);
}
});
var server = http.createServer(function(req, res) {
if(req.url == "/sample.html") {
fs.readFile("sample.html", function(err, text){
res.setHeader("Content-Type", "text/html");
res.end(text);
});
return;
}
res.setHeader("Content-Type", "text/html");
res.end("Hello World");
});
server.listen(8000, "127.0.0.1");
# Usage
$ npm install someModule
# Install Express
$ npm install express
# Install Socket.IO
$ npm install socket.io
Node Inspector is a debugger interface for Node.js
using the WebKit Web Inspector.
# Install node-inspector
$ npm install -g node-inspector
# Run your app
node --debug app
#Run node-inspector (in a separate window)
$ node-inspector
Browse to address given by node-inspector,
select source file to browse, set breakpoint,
and browse to your app.