#!/usr/bin/perl use CGI::Carp qw(fatalsToBrowser); use lib "$ENV{'DOCUMENT_ROOT'}/cgi-bin"; use JSON; use utf8; use incl::HTMLtest; use AI::Chat; use strict; use warnings; if ($data{'userChat'}) { my $reply = {}; $reply->{'response'} = $data{'userChat'}; print "Content-type: application/json\n\n"; print encode_json $reply; exit; } print<<"END_HTML"; Content-type: text/html; charset=UTF-8
END_HTML ####
my @pairs = split /&/, $query_string;
foreach my $p(@pairs) {
$p =~ tr/+/ /;
$p =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
my ($key, $val) = split /=/, $p, 2;
$data{$key} = $val;
}