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

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

Thread Previous | Thread Next
From:
Daisuke Maki
Date:
June 2, 2013 08:49
Subject:
Re: CGI.pm is dead, long live CGI.pm
Message ID:
CAK_8zA5C1sb=CYSMN3Kin4UMgR_ayNxVSnwTvuqmEkM8XU0yPw@mail.gmail.com
% cat > app.cgi
package main;
use Plack::Request;

my $app = sub {
    my $env = shift;
    my $req = Plack::Request->new($env);
    my $params = $req->parameters;
    return [ 200, [ "Content-Type" => "text/plain" ], [ map { sprintf ("%s
= %s\n", $_ => $params->get($_)) } $params->keys ] ];
};
Plack::Handler::CGI->new->run($app);

% cat `perldoc -l Plack::Handler::CGI` app.cgi > app_bundled.cgi

Plack::Request comes with Plack.

--d

2013/6/2 Eric Brine <ikegami@adaelis.com>

> On Tue, May 28, 2013 at 7:57 AM, Tatsuhiko Miyagawa <miyagawa@gmail.com>wrote:
>
>> On Tue, May 28, 2013 at 8:28 PM, Johan Vromans <jvromans@squirrel.nl>
>> wrote:
>> > Aristotle Pagaltzis <pagaltzis@gmx.de> writes:
>> >
>> > The bottom line is that my CGI solution requires 10-20 lines of code,
>> > works out of the box on any web host with Perl, without the need for
>> > additional modules and server (re)configuration.
>> >
>> > I have yet to see Plack code that does the same.
>>
>>     % 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
>>
>
> A program that takes no input is useless. What would it take to also
> process query and POST params?
>
>

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