Skip to content

Instantly share code, notes, and snippets.

@raminious
Created October 7, 2014 07:00
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 raminious/c5c22a4c4aee7b00345e to your computer and use it in GitHub Desktop.
Save raminious/c5c22a4c4aee7b00345e to your computer and use it in GitHub Desktop.
var http = require('http');
var path = require('path');
var fs = require('fs');
//var stream = require('stream');
http.createServer(function (req, res) {
var filename = [__dirname, 'file.mp3'].join(path.sep);
fs.stat(filename, function(error, stats){
var stream = fs.createReadStream(filename);
stream.on('data', function(data) {
res.write(data);
});
stream.on('end', function(){
res.end();
});
});
})
.listen(1337, '127.0.0.1');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment