Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: CGI package recommendation

by duelafn (Parson)
on Jan 24, 2021 at 20:15 UTC ( [id://11127399]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11127399]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-19 17:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found