Add /static to PSGI app for easier testing
This commit is contained in:
parent
2939e65214
commit
80e5249d54
6
app.psgi
6
app.psgi
|
@ -5,6 +5,7 @@ use warnings;
|
||||||
|
|
||||||
use Data::Random qw(rand_enum);
|
use Data::Random qw(rand_enum);
|
||||||
use Plack::App::File;
|
use Plack::App::File;
|
||||||
|
use Plack::Builder;
|
||||||
use YAML::XS qw(LoadFile);
|
use YAML::XS qw(LoadFile);
|
||||||
use Template;
|
use Template;
|
||||||
|
|
||||||
|
@ -38,7 +39,9 @@ sub generate_genre {
|
||||||
return join ' ', map { ucfirst } @genre;
|
return join ' ', map { ucfirst } @genre;
|
||||||
}
|
}
|
||||||
|
|
||||||
my $app = sub {
|
builder {
|
||||||
|
mount '/static' => Plack::App::File->new(root => 'static')->to_app(),
|
||||||
|
mount '/' => sub {
|
||||||
my $genre = generate_genre();
|
my $genre = generate_genre();
|
||||||
my $out = '';
|
my $out = '';
|
||||||
$template->process('index.tt', { genre => $genre }, \$out);
|
$template->process('index.tt', { genre => $genre }, \$out);
|
||||||
|
@ -47,4 +50,5 @@ my $app = sub {
|
||||||
[ 'Content-Type' => 'text/html' ],
|
[ 'Content-Type' => 'text/html' ],
|
||||||
[ $out ]
|
[ $out ]
|
||||||
];
|
];
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue