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 file from document
21 root if the path matches with the local file. Use Plack::App::Directory
22 if you want to list files in the directory as well.
23
25 root
26 Document root directory. Defaults to "." (current directory)
27
28 file
29 The file path to create responses from. Optional.
30
31 If it's set the application would ALWAYS create a response out of
32 the file and there will be no security check etc. (hence fast). If
33 it's not set, the application uses "root" to find the matching
34 file.
35
36 encoding
37 Set the file encoding for text files. Defaults to "utf-8".
38
39 content_type
40 Set the file content type. If not set Plack::MIME will try to
41 detect it based on the file extension or fall back to "text/plain".
42 Can be set to a callback which should work on $_[0] to check full
43 path file name.
44
46 Tatsuhiko Miyagawa
47
49 Plack::Middleware::Static Plack::App::Directory
50
51
52
53perl v5.32.0 2020-12-02 Plack::App::File(3)