Skip to content

Instantly share code, notes, and snippets.

@jessecravens
Created November 26, 2012 22:16
Show Gist options
  • Save jessecravens/4151028 to your computer and use it in GitHub Desktop.
Save jessecravens/4151028 to your computer and use it in GitHub Desktop.
NodeJS Hacks - Streams - Web
exports.example0 = function(req, res){
var http = require('http'),
fs = require('fs'),
util = require('util');
// Get html5hacks.com
require('http').get("http://html5hacks.com/", function(response) {
// The callback provides the response readable stream.
// Then, we open our output text stream.
var outStream = require('fs').createWriteStream("html5hacks.txt");
// Pipe the input to the output, which writes the file.
response.pipe(outStream);
});
res.render('example0', { title: 'Example0' })
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment