Created
March 27, 2011 22:28
-
-
Save norm/889709 to your computer and use it in GitHub Desktop.
Perl plackup script to serve up static content, used by dotjs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 <[email protected]> | |
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