• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
breve introduzione a node.js
 

breve introduzione a node.js

on

  • 520 views

Una breve, brevissima introduzione a node.js.

Una breve, brevissima introduzione a node.js.

Statistics

Views

Total Views
520
Views on SlideShare
518
Embed Views
2

Actions

Likes
0
Downloads
1
Comments
0

2 Embeds 2

http://nodeslide.herokuapp.com 1
http://www.docseek.net 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    breve introduzione a node.js breve introduzione a node.js Presentation Transcript

    • Un progetto di Ryan DahlUna presentazione di Eugenio Pombi NetMeansNet s.n.c.
    • Node.js èServer-side JavaScript interpreterScritto in C++Event driven (non blocking I/O)
    • $result = mysql_query(SELECT * WHERE 1=1);//do something Cosa fa apache mentre vengono recuperati i dati in attesa di essere mostrati?
    • Aspetta...E tiene impegnate risorse hardware nellattesa (RAM e CPU) Apache apre un thread per ogni nuova connessione
    • $result = mysql_query(SELECT * WHERE 1=1);//do something Questo codice implica che lintero processo si blocca durante lattesa Oppure Multiple execution stacks
    • Event Loopdb.query(SELECT * WHERE 1=1, function(result){ //do something});Questo codice permette di tornare allevent loop liberando le risorse Javascript evented programming
    • //server.jsvar sys = require( "util" ), http = require( "http" );http.createServer( function( request, response ) { response.writeHead( 200, {"Content-Type": "text/html"} ); response.write( "Hello World!" ); response.close();}).listen( 8080 );sys.puts( "Server running at http://localhost:8080" );
    • var sys = require("util"),// [...] http, url, path, fshttp.createServer(function(request, response) { var uri = url.parse(request.url).pathname; var filename = path.join(process.cwd(), uri); path.exists(filename, function(exists) { if(!exists) { response.writeHead(404, {"Content-Type": "text/plain"}); response.write("404 Not Foundn"); response.end(); return; } fs.readFile(filename, "binary", function(err, file) { if(err) { response.writeHead(500, {"Content-Type": "text/plain"}); response.write(err + "n"); response.end(); return; } response.writeHead(200); response.write(file, "binary"); response.end(); }); });}).listen(8080);sys.puts("Server running at http://localhost:8081/");
    • Cosa può fareLeggere cookieRicevere dati da formRicevere dati dalla querystringGestire gli headerUploadare filesFile streamingP2P (chat e simili)[...]Sistema modulare (npm)
    • Framework Express Geddy TDD ready Expresso nodeUnit Consigli Occhio ai tutorial con codice vecchio ;) response.close() > response.end()var sys = require("sys") > var util = require("util") http://nodetuts.com http://jsconf.eu/2009/video_nodejs_by_ryan_dahl.html
    • GRAZIE Eugenio Pombieugenio@netmeans.net @euxpom info@netmeans.net