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