justatheory.com
- Website: justatheory.com/
- About: I blog about Perl.
Recent Actions
-
Commented on A quick static file webserver
From my aliases file: alias pws="plackup -MPlack::App::File -e 'Plack::App::File->new->to_app'" Easy, just Plack. Only downside is that directory requests don’t work....
-
Commented on CPAN is all broken, now
Test::Pod has always failed on warnings, IIRC. There is just a new warning....
Comment Threads
-
preaction commented on
A quick static file webserver
I think I stole this snippet from Chromatic, same thing as Theory’s, with index.html support:
#!/usr/bin/env perl package Plack::App::IndexFile; use parent 'Plack::App::File'; sub locate_file { my ($self, $env) = @_; my $path = $env->{PATH_INFO} || ''; return $self->SUPER::locate_file( $env ) unless $path && $path =~ m{/$}; $env->{PATH_INFO} .= 'index.html'; return $self->SUPER::locate_file( $env ); } package main; use Plack::Runner; my $app = Plack::App::IndexFile->new({ root => shift })->to_app; my $runner = Plack::Runner->new; $runner… -
David E. Wheeler commented on
A quick static file webserver
Oh, thanks for that, preaction! Based on your code, I’ve written a short shell function:
pws () { plackup -MPlack::App::File -e ' package PWS; use parent "Plack::App::File"; sub locate_file { $_[1]->{PATH_INFO} .= "index.html" if $_[1]->{PATH_INFO} =~ m{/$}; $_[0]->SUPER::locate_file($_[1]); } PWS->new->to_app; ' }Pretty damned simple!
-
BooK commented on
A quick static file webserver
There’s also wallflower, that does it for any Plack application. (Full disclosure: I wrote it.)
When writing a static version of your application, there are a few things to consider, though.
-
BooK commented on
A quick static file webserver
Obviously, I didn’t understand the original post.
-
Enkidu commented on
A quick static file webserver
That’s what I’ve been looking for the last 2 months. Too many web servers on CPAN and too few Neil Bowers to sift through them all. That’s something that I can proudly share with my non-Perl friends.
About blogs.perl.org
blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.