Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I accept this way:
#!/usr/bin/env perl use Mojolicious::Lite; # Documentation browser under "/perldoc" plugin 'PODRenderer'; sub validate { my $input=shift; $input =~ s/\W/_/g; return $input; }; get '/' => sub { my $c = shift; $c->render('index'); }; get '/view/:ticket' => sub { my $c = shift; my $ticket = validate($c->param('ticket')); $c->render( 'ticketing', ticket => $ticket, ); }; app->start; __DATA__ @@ index.html.ep % layout 'default'; % title 'Welcome'; Welcome to the Mojolicious real-time web framework! @@ layouts/default.html.ep <!DOCTYPE html> <html> <head><title><%= title %></title></head> <body><%= content %></body> </html> @@ ticketing.html.ep % layout 'default'; % title 'Ticket Viewing'; <h1>This is where the business happens for <%= $ticket %></h1>
./Ticketing get '/view/12312`asdf`' [Mon Jun 22 13:13:10 2015] [debug] Your secret passphrase needs to be +changed!!! [Mon Jun 22 13:13:10 2015] [debug] GET "/view/12312%60asdf%60". [Mon Jun 22 13:13:10 2015] [debug] Routing to a callback. [Mon Jun 22 13:13:10 2015] [debug] Rendering template "ticketing.html. +ep" from DATA section. [Mon Jun 22 13:13:10 2015] [debug] Rendering template "layouts/default +.html.ep" from DATA section. [Mon Jun 22 13:13:10 2015] [debug] 200 OK (0.011596s, 86.237/s). <!DOCTYPE html> <html> <head><title>Ticket Viewing</title></head> <body> <h1>This is where the business happens for 12312_asdf_</h1 +> </body> </html>
Using Mojolicious is a great way to do small web apps. They are well encapsulated and contain the primary functionality like logging, templating, debugging. You start out with one file using  mojo generate lite_app <name> and everything (webserver, logic, templates) is in one file. Later there are options for growing into a full fledged module and separating into more manageable aspects if needed.

In reply to Re: Good Style for Small Apps by trippledubs
in thread Good Style for Small Apps by Hermano23

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 studying the Monastery: (4)
As of 2024-03-29 09:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found