Created
August 7, 2012 05:57
-
-
Save heapwolf/3282141 to your computer and use it in GitHub Desktop.
http/media-stream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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