daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const url = require('url');
  2. const fs = require('fs');
  3. const path = require('path');
  4. const errorHandler = require('./error-handler')
  5.  
  6. module.exports = (req, res) => {
  7.   req.pathName = req.pathname || url.parse(req.url).pathname;
  8.  
  9.   if(req.pathName === '/viewAllMovies' && req.method === 'GET'){
  10.     let filePath = path.normalize(path.join(__dirname, '../views/viewAll.html'));
  11.     let stream = fs.createReadStream(filePath);
  12.     let previousData = '';
  13.  
  14.     stream.on('error',(err) =>{
  15.       errorHandler(err, res);
  16.       return;
  17.     })
  18.  
  19.     res.on('data',data =>{
  20.       console.log('-');
  21.     })
  22.  
  23.     res.writeHead(200, {
  24.       'Content-Type': 'text/html',
  25.     });
  26.  
  27.     stream..pipe(res);
  28.  
  29.   } else {
  30.     return true;
  31.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top