Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 9c2b8ec544a102eb51d4faff955b14f91f4529bc @davorg committed Aug 27, 2012
Showing with 34 additions and 0 deletions.
  1. +5 −0 README
  2. +29 −0 rand_image/rand_img.psgi
5 README
@@ -0,0 +1,5 @@
+This will eventually become a set of PSGI[1] applications that replicate all of the scripts found in Matt's Script Archive[2] and the nms[3] project.
+
+[1] http://plackperl.org/
+[2] http://www.scriptarchive.com/
+[3] http://nms-cgi.sourceforge.net/
29 rand_image/rand_img.psgi
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use 5.010;
+
+use Dancer;
+
+my $img_dir = 'public/img';
+
+get '/' => sub {
+ opendir my $dir, $img_dir or die $!;
+ my @imgs = grep { -f "$img_dir/$_" } readdir $dir;
+ my $img = @imgs[rand @imgs];
+
+ warn $img;
+
+ return redirect "/img/$img";
+};
+
+get '/img/:img' => sub {
+ return send_file 'img/' . params->{img};
+};
+
+get '/test' => sub {
+ return '<img src="/" />';
+};
+
+dance;

0 comments on commit 9c2b8ec

Please sign in to comment.