Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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?


In reply to I cannot execute a url request through Dancer by logangha

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (6)
As of 2024-04-19 15:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found