Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- const path = require('path');
- function showFile(folderName, done) {
- fs.readdir(path.join('./public', folderName), (err, files) => {
- files.some(file => {
- done('http://localhost/public/' + folderName + '/' + file.toString());
- });
- });
- }
- ///
- app.get('/:id', (req, res) => {
- showFile(req.params.id, file => {
- res.render('index', {title: req.params.id, img: file});
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement