Saturday, December 17, 2016

Node.js Tutorial for Beginners 13 - pipes





var fs = require('fs');
var http = require('http');


http.createServer(function (req, res) {
   // Send the HTTP header 
   // HTTP Status: 200 : OK
   // Content Type: text/plain

   res.writeHead(200, {'Content-Type': 'text/plain'});   
   var readStream = fs.createReadStream('file.txt', 'utf8');
   readStream.pipe(res);
}).listen(3000);

// Console will print the message
console.log("server is running on http://127.0.0.1:3000/")

Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com


Stuff I use to make videos

Windows notebook - http://amzn.to/2ADOPrW

Apple MacBook Pro - http://amzn.to/2AC0WG2

Microphone - http://amzn.to/2AC1kV0

notebook mouse - http://amzn.to/2BmeZ2d