Created
October 7, 2014 07:00
-
-
Save raminious/c5c22a4c4aee7b00345e to your computer and use it in GitHub Desktop.
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 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