Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save cdario/6102952 to your computer and use it in GitHub Desktop.
Save cdario/6102952 to your computer and use it in GitHub Desktop.
Reads a file from the server, and write its contents (HTML). Non-blocking calls.
var http = require('http');
var fs = require('fs');
http.createServer(function(request, response) {
response.writeHead(200, {'Content-Type': 'text/html'});
fs.readFile('index.html', function(err, contents) {
response.write(contents);
response.end();
});
}).listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment