Skip to content

Instantly share code, notes, and snippets.

@chaiwa-berian
Last active August 20, 2018 17:28
Show Gist options
  • Save chaiwa-berian/8e1d60dc8e999817b9601164020b9169 to your computer and use it in GitHub Desktop.
Save chaiwa-berian/8e1d60dc8e999817b9601164020b9169 to your computer and use it in GitHub Desktop.
Nodejs Streams
const http = require('http');
const fs = require('fs');
var server = http.createServer((req,res)=>{
fs.readFile(__dirname + '/data.txt', function(err, data){
if(err){
res.end(err);
}
res.end(data);
}
});
server.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment