I have Json Rpc Dispatcher Server running in my local host at port 5000 I need to get a html index page when i visit
http://localhost:5000
here is the app.psgi use JSON::RPC::Dispatcher;
my $rpc = JSON::RPC::Dispatcher->new;
$rpc->register( 'ping', sub { return 'pong' } );
$rpc->register( 'echo', sub { return $_[0] } );
sub add_em {
my @params = @_;
my $sum = 0;
$sum += $_ for @params;
return $sum;
}
$rpc->register( 'sum', \&add_em );
# Want to do some fancy error handling?
sub guess {
my ($guess) = @_;
if ($guess == 10) {
return 'Correct!';
}
elsif ($guess > 10) {
die [ 986, 'Too high.', $guess];
}
else {
die [ 987, 'Too low.', $guess ];
}
}
$rpc->register( 'guess', \&guess );
For now it only returns json with either a GET guess or sum method request.
I need to have a GET request that will return a html page and load some Javascript maybe with the root request
http://localhost:5000/
According to the JSON-RPC 2.0
Specification:
When a rpc call is made, the Server MUST reply with a Response, except for in the case of Notifications. The Response is expressed as a single JSON Object, ...
So its not possible to get a html page from a JSON::RPC Server.