develooper Front page | perl.perl5.porters | Postings from May 2013

Re: CGI.pm is dead, long live CGI.pm

Thread Previous | Thread Next
From:
Johan Vromans
Date:
May 28, 2013 13:44
Subject:
Re: CGI.pm is dead, long live CGI.pm
Message ID:
m27gij5ida.fsf@phoenix.squirrel.nl
Tatsuhiko Miyagawa <miyagawa@gmail.com> writes:

>     % cat > app.cgi
>     package main;
>
>     my $app = sub {
>         return [ 200, [ "Content-Type", "text/html" ], [ "Hello" ] ];
>     };
>     Plack::Handler::CGI->new->run($app);
>
>     % cat `perldoc -l Plack::Handler::CGI` app.cgi > app_bundled.cgi

Plack/Handler/CGI.pm ends with __END__ and a pod section, effectively
causing the contents of app.cgi to be ignored.

But we can fix that ;)

> Now app_bundled.cgi works as a CGI script, no dependencies out of the
> core (Plack::Handler::CGI only requires strict.pm and IO::Handle). FTP
> that file, chmod +x it and it works as a CGI script on any host.

Right. Now this is really helpful.

>     $ cat > myapp.pl
>     use Mojolicious::Lite;
>     get '/' => sub {
>       my $self = shift;
>       $self->render(text => "Hi");
>     };
>     app->start;

So is this. Thanks.

-- Johan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About