slideshow.io/routes/viewer/index.js

26 lines
536 B
JavaScript
Raw Normal View History

2016-09-09 17:20:59 +01:00
var fs = require('fs');
module.exports.index = function(req, res, render, next) {
fs.stat('static/uploaded/' + req.params.file + '.pdf', function(err) {
if (err === null) {
res.locals.file = req.params.file;
res.setHeader('Content-Type', 'text/html');
render('index.pug', res.locals);
} else {
// 404 : file does not exist
var error = new Error('File does not exist');
error.status = 404;
next(error);
}
});
}