http://qs321.pair.com?node_id=11127399


in reply to CGI package recommendation

If you're looking for something with that same do-it-yourself feel, I've been using the following template for small one-off scripts. Not apppropriate for a site full of CGI, but if you have a static site with just a couple simple independent dynamic pages, it can be sufficient.

use strict; use warnings; use 5.020; use utf8; use Plack::Request; use Encode; use JSON::XS; my $app = sub { my $req = Plack::Request->new($_[0]); my $input = decode 'UTF-8', $req->parameters->{'input'}; [ 200, [ 'Content-Type', 'application/json; charset=UTF-8' ], [ encode_json { output => uc $input } ] ]; }; # To run as a true CGI script, include after the sub: #use Plack::Handler::CGI; #Plack::Handler::CGI->new->run($app); # Or FastCGI for reverse proxy: # plackup -s FCGI --listen /tmp/fcgi.sock myapp.psgi # Or persistently for simple direct serve: # plackup --host 127.0.0.1 --port 9090 script.pl

Good Day,
    Dean