Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Perl plackup script to serve up static content, used by dotjs.
#!/usr/bin/env perl
#
# Perl script to serve up ~/etc/static on localhost. I use this in
# conjunction with my fork of the "dotjs" Safari extension (found
# at https://github.com/norm/dotjs.safariextension) to serve up
# JS and CSS.
#
# Requires Plack and Plack::Middleware::Header. Best installed with cpanm
# ("sudo cpanm Plack Plack::Middleware::Header"). Cpanm, and instructions
# on installing it can be found at http://cpanmin.us/.
#
# Save the script somewhere (I suggest ~/bin/etcstatic), then run:
# "plackup -p 3131 <saved_script_filename>"
#
# Mark Norman Francis <norm@cackhanded.net>
use Plack::Builder;
my $app = sub {
return [
200,
[],
[],
];
};
builder {
enable 'Header',
set => [ 'Access-Control-Allow-Origin' => '*' ];
enable
"Plack::Middleware::Static",
path => qr{^/},
root => "$ENV{'HOME'}/etc/static",
pass_through => 1;
$app;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment