Plack::App::File(3)
β¨ NAME β¨
Plack::App::File β bestie, it serves static files from a root directory π
πΈ SYNOPSIS πΈ
use Plack::App::File;
my $app = Plack::App::File->new(root => "/path/to/htdocs")->to_app;
# Or map the path to a specific file
use Plack::Builder;
builder {
mount "/favicon.ico" => Plack::App::File->new(file => '/path/to/favicon.ico')->to_app;
};
no cap, that's the whole vibe check π
π¦ DESCRIPTION π¦
Okay so this is a static file server PSGI application, and internally it's the one doing the heavy lifting for Plack::Middleware::Static π. It serves files straight out of the document root whenever the path matches up with an actual local file, periodt.
If you also want to list what's chillin' in a directory (like, actually show the contents), then go grab Plack::App::Directory instead β this one here isn't giving director energy, it's giving "here's your file, bye" π.
π CONFIGURATION π
rootβ the document root directory, aka where your files live. Defaults to"."(current directory), lowkey convenient.fileβ the file path to create responses from. Optional, bestie.
If it's set, the application would ALWAYS create a response out of the file, and there will be no security check etc. (hence fast, we love a speedy queen β‘). If it's not set, the application uses root to find the matching file instead.
encodingβ sets the file encoding for text files. Defaults to"utf-8"π.content_typeβ sets the file content type. If you don't set it,Plack::MIMEwill try to detect it based on the file extension, or fall back to"text/plain". It can also be set to a callback, which should work on$_[0]to check the full path file name π₯.
π AUTHOR π
Tatsuhiko Miyagawa β legend behavior, fr fr π«Ά
π SEE ALSO π
Plack::Middleware::Static Plack::App::Directory
go read those too, iykyk π
okay that's the whole page, mwah π β this was perl v5.42.3, dated 2026-10-18, and it's the Plack::App::File(3) manual. slay, go serve some files bestie πβ¨
π¦ where this page comes from
- fedora 43: perl-Plack 1.0055-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-Plack 1.0055-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms