Stream Pipes in NodeJs
stream.pipe(), The method used to take a readable stream and connect it to a writeable stream.
outputconst fs = require('fs');const http = require('http')const server = http.createServer();server.on('request',(req, res)=>{const rstream = fs.createReadStream('index.txt');rstream.pipe(res);});server.listen(8000, "127.0.0.1");
Post a Comment