Skip to content

Instantly share code, notes, and snippets.

@alexcoleman
Last active December 18, 2015 11:49
Show Gist options
  • Select an option

  • Save alexcoleman/5778024 to your computer and use it in GitHub Desktop.

Select an option

Save alexcoleman/5778024 to your computer and use it in GitHub Desktop.
// Photos
app.get('/photos', function (req, res, next) {
var view = {};
fs.readdir('./public/img/slideshow', function(err, files) {
var re = /\.(gif|jpg|jpeg|tiff|png)$/i;
var list = files.filter(function (file) {
return re.test(file);
});
var randomPhotoIndex = Math.floor(Math.random() * list.length);
view.photo = list[randomPhotoIndex];
res.render('photos', view);
});
});
Copy link
Copy Markdown

ghost commented Jun 13, 2013

CR passed, good codez

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment