See: http://www.cpantesters.org/cpan/report/33267be8-a901-11e1-b995-c5a3320db69d
Now have a look at the POD in that file, it's all ASCII. There is a UTF-8 character in the file, but not in the POD.
]]>What actually changed?
]]>#!/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->parse_options( '--access-log' => '/dev/null', @ARGV ); $runner->run( $app );
These little http scripts work great when I need to read Devel::Cover and Devel::NYTProf reports on a remote system (and I’m gonna try http_this).
]]>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!
]]>When writing a static version of your application, there are a few things to consider, though.
]]>I needed this for a particular project so I haven’t stopped to make it pretty.
]]>render_static
was deprecated in the middle of the Mojolicious 5 evolution and is now reply->static
:
#!/usr/bin/env perl use Mojolicious::Lite; use Cwd; app->static->paths->[0] = getcwd; any '/' => sub { shift->reply->static('index.html'); }; app->start;]]>