Created
January 26, 2018 01:16
-
-
Save fbn4sc/8117de785a193346728bf1e4ad164773 to your computer and use it in GitHub Desktop.
Stream the contents of a file via http
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
const http = require("http"); | |
const fs = require("fs"); | |
const server = http.createServer((req, res) => { | |
fs | |
.createReadStream(process.argv[3]) | |
.on("data", data => res.write(data)) | |
.on("end", () => res.end()); | |
}); | |
server.listen(process.argv[2]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment