Skip to content

Instantly share code, notes, and snippets.

@valdiney
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valdiney/8794145 to your computer and use it in GitHub Desktop.
Save valdiney/8794145 to your computer and use it in GitHub Desktop.
Meus primeiros passos com Node.js!! Chamando uma página html
var http = require('http'),
arquivo = require('fs');
var servidor = http.createServer( function( request, response ) {
arquivo.readFile('paginas/index.html', function( err, html ) {
response.writeHead(200, {"Content-Type": "text/html"});
if( err ) response.write('Este arquivo nao foi encontrado!');
response.write( html );
response.end();
});
});
servidor.listen(3000, function() {
console.log('Servidor está nor ar!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment