Skip to content

Instantly share code, notes, and snippets.

@NV
Created August 22, 2010 12:20
Show Gist options
  • Select an option

  • Save NV/543714 to your computer and use it in GitHub Desktop.

Select an option

Save NV/543714 to your computer and use it in GitHub Desktop.
var sys = require('sys'),
http = require('http'),
fs = require('fs');
var FILENAME = 'message.txt';
fs.writeFile(FILENAME, 'Hello Node', function (err) {
if (err) throw err;
console.log('It\'s saved!');
});
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end(fs.readFileSync(FILENAME));
}).listen(process.env.PORT || 8000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment