Serving a static site (the content of a directory) using Plack and PSGI
Just a simple example using Plack::Builder and Plack::App::File to serve some static files using a Perl-based web server.
examples/static_psgi/app.psgi
use strict; use warnings; use Plack::Builder; use Plack::App::File; my $app = Plack::App::File->new(root => "www")->to_app; builder { enable "DirIndex", dir_index => 'index.html'; $app; }
Put this in a directory as app.psgi. Put your HTML files in the 'www' subdirectory. Run plackup and you can visit http://127.0.0.1:5000/ to see the pages.
In this code we use the Plack::Middleware::DirIndex middleware that handles the files in the given directory.
Check out the other articles on Plack/PSGI.

Published on 2017-05-13
Comments
In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation. comments powered by Disqus
If you have any comments or questions, feel free to post them on the source of this page in GitHub. Source on GitHub.
Comment on this post