Skip to content

Instantly share code, notes, and snippets.

@sethetter
Created April 26, 2014 17:46
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 sethetter/11326427 to your computer and use it in GitHub Desktop.
Save sethetter/11326427 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
Readable = require('stream').Readable,
http = require('http'),
port = 4000,
count = 0,
server;
server = http.createServer(function(req, res) {
var stream = new Readable;
count++;
stream.push('This is a stream!');
stream.push('\n');
stream.push('Count: ' + count);
stream.push('\n');
stream.push('--------------------');
stream.push('\n');
stream.push(null);
stream.pipe(process.stdout);
stream.pipe(res);
});
server.listen(port);
console.log('Listening on localhost:' + port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment