Created
August 20, 2018 19:04
-
-
Save chaiwa-berian/b9e3002460e010b90bcf92e32cf83a1e to your computer and use it in GitHub Desktop.
Read a big file without using streams
This file contains hidden or 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 fs = require('fs'); | |
const server = require('http').createServer(); | |
server.on('request', (req, res) => { | |
fs.readFile('./big.file', (err, data) => { | |
if (err) throw err; | |
res.end(data); | |
}); | |
}); | |
server.listen(8000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment