#!/usr/bin/env perl use strict; use warnings; use 5.020; use autodie; use Data::Dumper; use JSON; use CGI; use CGI::Carp qw(fatalsToBrowser); if (my $content_len = $ENV{CONTENT_LENGTH}) { read(STDIN, my $json, $content_len); my $href = decode_json($json); my $a = $href->{a}; my $b = $href->{b}; my $q = CGI->new; #Doesn't work with inets httpd server print $q->header, $q->start_html("Test Page"), $q->div("json=$json"), $q->div("a=$a"), $q->div("b=$b"), $q->end_html; #print 'Content-type: text/html'; #print "\r\n\r\n"; #print "
a=$a
"; #print "
b=$b
"; } else { my $error = "Could not read json: No Content-Length header in request."; #print 'Content-type: text/html'; #print "\r\n\r\n"; #print "
$error
"; my $q = CGI->new; print $q->header, $q->start_html("Test Page"), $q->h1($error), $q->end_html; }