How to create a simple webserver with node.js
routing with node.js
var http = require('http');
http.createServer(function(request,response)
{
var path = request.url.replace(/\/?(?:\?.*)?$/, '').toLowerCase();
switch(path)
{
case '':
response.writeHead(200,{'Content-Type':'text/plain'});
response.end('Hello World');
break;
case '/about':
response.writeHead(200,{'Content-Type':'text/plain'});
response.end('About');
break;
default :
response.writeHead(404,{'Content-Type':'text/plain'});
response.end('Page Not Found');
break;
}
}
).listen(9999);
console.log("Server Started @ locahost:9999");
In questa pagina del sito puoi guardare il video online node.js as a simple web server della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Zariga Tongy 26 agosto 2014, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 766 volte e gli è piaciuto 5 spettatori. Buona visione!