logangha has asked for the wisdom of the Perl Monks concerning the following question:
Hi there
I am trying to make a request to a Dancer application which is initialized as I indicate:
# perl serv.pl
>> Dancer 1.3513 server 9802 listening on http://xxx.xx.xx.xx:xx
>> Dancer::Plugin::REST (0.11)
== Entering the development dance floor ...
But when I tried to execute below command
curl http://ipaddress:port/reference/C00-1412-0010
It shows this result:
curl http://ipaddress:port/reference/C00-1412-0010
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Error 500</title> <link rel="stylesheet" href="/css/style.css" /> <meta http-equiv="Content-type" content="text/html; charset=UTF-8" /> </head> <body> <h1>Error 500</h1> <div id="content"> <h2>Unable to process your query</h2>The page you requested is not ava +ilable </div> <div id="footer"> Powered by <a href="http://perldancer.org/">Dancer</a> 1.3513 </div> </body> </html>#
Below are all the functions called for this code.package MyWebService; use strict; use warnings; use Dancer; use Dancer::Plugin::REST; use Config::File::Simple; use File::Slurp; use URI::Encode qw(uri_encode uri_decode); use IO::Socket; use IO::Select; use Storable; use Tie::IxHash; use REST::Client; use MIME::Base64; set server => 'xxx.xx.xx.xx'; get '/reference/:reference' => sub { writeLog("Arrived reference: " . params->{reference}); my (@arrRes, @arrNoRes) = processRequest(params->{reference}); if (@arrNoRes > 0) { push(@arrRes, @arrNoRes); } my $jsonResponse; if (@arrRes == 0) { $jsonResponse = to_json { reference => params->{reference} } +; } else { writeLog("Found results: " . Dumper(\@arrRes)); $jsonResponse = encode_json(\@arrRes); } return $jsonResponse; }; dance; . . .
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: I cannot execute a url request through Dancer
by kcott (Archbishop) on Sep 23, 2022 at 02:47 UTC |