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>#
This is part of the 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;
.
.
.
Below are all the functions called for this code.
What is missing to allow this code works when it is invoked as a url with curl command?
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|