1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#!/usr/bin/env perl use Mojolicious::Lite; # Documentation browser under "/perldoc" plugin 'PODRenderer'; get '/' => sub { my $c = shift; $c->render('index'); }; post '/lo' => sub { my $c = shift; my @params = $c->req->body_params; $c->stash('all_post_params'=> join(',',@params) ); $c->stash('tx'=> $c->req->param('textentry') ); $c->stash('pw'=> $c->req->body_params->param('passw')); $c->stash('hid'=> $c->param('hid') ); $c->render('parameter'); }; # get rid of the secrets-warning app->secrets(['abcd']); app->start; __DATA__ @@ index.html.ep <!DOCTYPE html> <html> <head><title>Parameter Test</title></head> <body> <form action="/lo" method="post" enctype="text/plain"> <p>Textentry<br/> <input type="text" size="8" name="textentry" /></p> <hr/> <p>Password<br/> <input type="password" size="8" name="passw" /></p> <hr/> <input type="submit" value="send" name="1"/> <input type="submit" value="send anyway"/> <br/> <input type="hidden" value="<%=rand(5)%>" name="hid"/><br/> <a href="/">reload</a> </form> </body> </html> @@ parameter.html.ep <!DOCTYPE html> <html> <head><title>Parameter Results</title></head> <body> <p>Text: <strong><%=stash('tx')%></strong><br/> </p><hr/> <p>Password: <strong><%= param('passw') %></strong><br/> </p><hr/> <p>Hidden: <strong><%= param('hid') %></strong><br/> </p><hr/> <p>All POST-params:<strong> <%=stash('all_post_params')%></strong><hr/></p> <a href="/">again</a> </body> </html>
2014-10-08T07:59:21 MolafCode: (dl )1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16@@ parameter.html.ep
<!DOCTYPE html>
<html>
<head><title>Parameter Results</title></head>
<body>
<p>Text: <strong><%=stash('tx')%></strong><br/>
</p><hr/>
<p>Password: <strong><%= param('passw') %></strong><br/>
</p><hr/>
<p>Hidden: <strong><%= param('hid') %></strong><br/>
</p><hr/>
<p>All POST-params:<strong>
<%=stash('all_post_params')%></strong><hr/></p>
<a href="/">again</a>
</body>
</html>
<form action="/lo" method="post" enctype="text/plain">
http://mojolicio.us/perldoc/Mojolicious/Controller#param(...)as well as GET and POST parameters extracted from the query string and application/x-www-form-urlencoded or multipart/form-data message body, in that order.