Last active
August 29, 2015 13:56
-
-
Save valdiney/8794145 to your computer and use it in GitHub Desktop.
Meus primeiros passos com Node.js!! Chamando uma página html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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