Skip to content

Commit 1f37c81

Browse files
author
Geoffrey Broadwell
committed
Trivial Mojolicious::Lite app to serve static content from html dir; currently uses redirects instead of content negotiation
1 parent 3fb2dfe commit 1f37c81

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

app.pl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env perl
2+
3+
use Mojolicious::Lite;
4+
5+
my $app = $ENV{MOJO_APP};
6+
$app->{static}->root('html');
7+
8+
get '(*dir)/:file' => sub {
9+
my $self = shift;
10+
my $dir = $self->param('dir');
11+
my $file = $self->param('file');
12+
return $self->redirect_to("/$dir/$file.html");
13+
};
14+
15+
get '(*dir)/' => sub {
16+
my $self = shift;
17+
my $dir = $self->param('dir');
18+
return $self->redirect_to("/$dir/index.html");
19+
};
20+
21+
get '/' => sub {
22+
my $self = shift;
23+
return $self->redirect_to('/index.html');
24+
};
25+
26+
$app->start;

0 commit comments

Comments
 (0)