Skip to content

Instantly share code, notes, and snippets.

@heapwolf heapwolf/45.js
Created Aug 7, 2012

Embed
What would you like to do?
http/media-stream
var fs = require('fs');
require('http').createServer(function(req, res) {
if (req.url === '/') {
res.writeHead(200, {'Content-Type': 'video/x-m4v'});
var rs = fs.createReadStream(__dirname + '/video.m4v');
rs.pipe(res);
rs.on('data', function(d) {
console.log('sent', d.length, 'bytes')
});
rs.on('end', function() {
console.log('read stream ended.');
});
} else {
res.writeHead(404);
}
}).listen(4000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.