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::MIME will 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