1Plack::App::File(3) User Contributed Perl Documentation Plack::App::File(3)
2
3
4
6 Plack::App::File - Serve static files from root directory
7
9 use Plack::App::File;
10 my $app = Plack::App::File->new(root => "/path/to/htdocs")->to_app;
11
12 # Or map the path to a specific file
13 use Plack::Builder;
14 builder {
15 mount "/favicon.ico" => Plack::App::File->new(file => '/path/to/favicon.ico')->to_app;
16 };
17
19 This is a static file server PSGI application, and internally used by
20 Plack::Middleware::Static. This application serves files from the
21 document root if the path matches with the local file. Use
22 Plack::App::Directory if you want to list files in the directory as
23 well.
24
26 root
27 Document root directory. Defaults to "." (current directory)
28
29 file
30 The file path to create responses from. Optional.
31
32 If it's set the application would ALWAYS create a response out of
33 the file and there will be no security check etc. (hence fast). If
34 it's not set, the application uses "root" to find the matching
35 file.
36
37 encoding
38 Set the file encoding for text files. Defaults to "utf-8".
39
40 content_type
41 Set the file content type. If not set Plack::MIME will try to
42 detect it based on the file extension or fall back to "text/plain".
43 Can be set to a callback which should work on $_[0] to check full
44 path file name.
45
47 Tatsuhiko Miyagawa
48
50 Plack::Middleware::Static Plack::App::Directory
51
52
53
54perl v5.36.0 2023-01-20 Plack::App::File(3)