Plack::App::Hash - Serve up the contents of a hash as a website


version 1.000


 use Plack::App::Hash;
 my $app = Plack::App::Hash->new(
     content      => { '' => 'Hello World!' },
     default_type => 'text/plain',


This PSGI application responds to HTTP requests by looking up the request path in a hash and returning the value of that key (if found) as the response body.

This is useful for cases like inlining the content of a boilerplate static site into a single-page-application-in-a-module, or serving up a tied DBM hash that other programs can update while the web app itself contains very little logic – in short, for one-off hacks and scaling down.



The content of your site. Each key-value pair will be one resource in your URI space. The key is its URI path without leading slash, and the is the content of the resource. Values must not be references.

headers (optional)

The headers of your resources. As in content, each key is a URI path without leading slash. The value of a key may be either an array reference or a string containing a JSON encoding of an array. In either case it is taken to mean the PSGI header array for the resource.

auto_type (optional)

If true, a Content-Type header value will be computed automatically for any responses which do not already have one by way of the headers hash.

default_type (optional)

The Content-Type value to use for any responses which would not otherwise have one, whether by matching headers or by auto_type fallback.


Aristotle Pagaltzis <>


This software is copyright (c) 2015 by Aristotle Pagaltzis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.