[dancer-users] Help with a POST
Richard Reina
gatorreina at gmail.com
Fri Aug 7 15:45:06 BST 2015
Hi Andrew,
Let me answer your second question first -- as will bear insight to my
answer of the second question. I am using dancer instead of dancer2 because
I am too clueless to know any better. I will look to migrate to dancer2
although I am not sure what that entails -- hope my kids and wife remember
what I look like.
About how I call it. I am confused here as well. I am merely typing it in
the url. I am trying to create a new user login page that will ultimately
be a link from my home page. So I will need for it to work as
mydomain.com/user. I am afraid I don't know how else to "call" it and
confess that I don't completely understand what "call" it means. I just
don't want to use GET as it makes the info appears in the url.
Thanks again
2015-08-07 9:30 GMT-05:00 Andrew Solomon <andrew at geekuni.com>:
> Hi Richard
>
> How are you calling it? You can't just call it by putting the url in your
> browser since the browser will be making a GET request. I'd use curl as
> described here
>
>
> http://superuser.com/questions/149329/what-is-the-curl-command-line-syntax-to-do-a-post-request
>
> (or in the 'man curl' page if you read it slowly:)
>
> Next question - why are you using Dancer instead of Dancer2?
>
> Dancer2 is a redesign to make things more easy/powerful/enjoyable...
>
> Andrew
>
>
> On Fri, Aug 7, 2015 at 3:17 PM, Richard Reina <gatorreina at gmail.com>
> wrote:
>
>> I am hoping someone can help me understand how to get this to work as a POST instead of GET.
>> When I do sub below as 'get' it works but when I replace 'get' with 'post' I get:--2015-08-06 13:52:05-- http://0.0.0.0:3000/userConnecting to 0.0.0.0:3000... connected.HTTP request sent, awaiting response... 404 Not Found2015-08-06 13:52:05 ERROR 404: Not Found.package MyApp;use Dancer ':syntax';use Dancer::Plugin::FormValidator;our $VERSION = '0.1';post '/user' => sub { my $input_hash = { FName => param('firstname'), LName => param('lastname'), Email => param('email'), Terms => param('terms'), }; my $number_of_defined_values = scalar grep { defined } values %{$input_hash}; $number_of_defined_values = $number_of_defined_values + 0; if ($number_of_defined_values > 1) { my $error = form_validator_error( 'profile_user', $input_hash ); if ( ! $error ) { #the user provided complete and validates data it's cool to proceed } else { my %hash = %$error; foreach my $k (keys %hash) { return "$k: $hash{$k}\n"; } } } template 'user';##########################################################}; ### end of sub user ###################################true;Thanks in advance for any help.
>>
>>
>> _______________________________________________
>> dancer-users mailing list
>> dancer-users at dancer.pm
>> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>>
>>
>
>
> --
> Andrew Solomon
>
> Mentor at Geekuni http://geekuni.com/
> http://www.linkedin.com/in/asolomon
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150807/87a3d542/attachment.html>
More information about the dancer-users
mailing list