diff options
Diffstat (limited to 'template/perl/base-psgi-static.pl')
-rw-r--r-- | template/perl/base-psgi-static.pl | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/template/perl/base-psgi-static.pl b/template/perl/base-psgi-static.pl new file mode 100644 index 0000000..aebf116 --- /dev/null +++ b/template/perl/base-psgi-static.pl @@ -0,0 +1,24 @@ +use strict; +use warnings; +use Plack::Builder; +use Plack::Request; + +my $app = sub { + my $env = shift; + my $req = Plack::Request->new($env); + return root($req) if $req->path eq '/'; + [ 404, [ "Content-Type" => "text/plain" ], ["Not Found"] ]; +}; + +sub root { + my $req = shift; + my $res = $req->new_response(200); + $res->content_type('text/html'); + $res->body('hello world'); + $res->finalize(); +} + +builder { + enable "Plack::Middleware::Static", path => qr/static/, root => '.'; + $app; +}; |