Skip to content

Instantly share code, notes, and snippets.

@norm
Created March 27, 2011 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norm/889709 to your computer and use it in GitHub Desktop.
Save norm/889709 to your computer and use it in GitHub Desktop.
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