slideshow.io/routes/speaker/index.js

26 lines
536 B
JavaScript

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);
}
});
}