#!/usr/bin/perl --
use strict;
use warnings;
use CGI ();
use CGI::Carp qw(fatalsToBrowser);
use JSON ();
my $q = CGI->new;
my $data = $q->param('POSTDATA') ;
#~ my $data = $q->param('POSTDATA') || '{"a":100,"b":300}';
my $json = JSON->new->utf8;
my $input = $json->decode( $data );
my $a = $input->{a};
my $b = $input->{b};
my $c = $a + $b;
print $q->header("application/json");
print $json->encode({ c => $c });
####
#!/usr/bin/perl --
use strict;
use warnings;
use CGI ();
use CGI::Carp qw(fatalsToBrowser);
use JSON ();
Main( @ARGV );
exit( 0 );
sub Main {
binmode STDOUT;
my $q = CGI->new;
my $cb = AddJsonGetBytes( $q );
print $q->header("application/json"), $cb;
return;
}
sub AddJsonGetBytes {
my( $q ) = @_;
my $data = $q->param('POSTDATA') ;
my $json = JSON->new->utf8;
my $input = $json->decode( $data );
my $a = $input->{a};
my $b = $input->{b};
my $c = $a + $b;
return $json->encode({ c => $c });
}
##
##
#!/usr/bin/perl --
use strict;
use warnings;
use CGI ();
use CGI::Carp qw(fatalsToBrowser);
use JSON ();
Main( @ARGV );
exit( 0 );
sub Main {
binmode STDOUT;
my $q = CGI->new;
my $cb = AddJsonGetBytes( $q );
print $q->header("application/json"), $cb;
return;
}
sub AddJsonGetBytes {
my( $q ) = @_;
my $json = JSON->new->utf8;
my $data = $q->param('POSTDATA') ;
if( not defined $data ){
return $json->encode({ error => 'no valid input' });
}
my $input = $json->decode( $data );
my $a = $input->{a};
my $b = $input->{b};
my $c = $a + $b;
return $json->encode({ c => $c });
}
##
##
#!/usr/bin/perl --
use strict;
use warnings;
use CGI ();
use CGI::Carp qw(fatalsToBrowser);
use JSON ();
Main( @ARGV );
exit( 0 );
sub Main {
binmode STDOUT;
my $q = CGI->new;
my $json = JSON->new->utf8;
my $cb = AddJsonGetBytes( $q , $json );
print $q->header("application/json"), $cb;
return;
}
sub AddJsonGetBytes {
my( $q, $json ) = @_;
my $data = $q->param('POSTDATA') ;
if( not defined $data ){
return $json->encode({ error => 'no valid input' });
}
my $input = $json->decode( $data );
my $a = $input->{a};
my $b = $input->{b};
my $c = $a + $b;
return $json->encode({ c => $c });
}