If rephrased the original post to be a little less technical, maybe that is
easier for beginners to grasp (although I quite like the original
proposal).
We may use logging to to show the simplicity. I'm not completely convinced
as it makes the example maybe to verbose.
my $title = $c->ua->get($url)->res->dom->at('title')->text;
+ $c->app->log->debug("Retrieved title from URL $url: $title");
$c->send($title);
Running the application is as simple as:
sh# morbo test.pl
[Thu Sep 18 20:47:09 2014] [info] Listening at "http://*:3000".
Server available at http://127.0.0.1:3000.
[Thu Sep 18 20:47:12 2014] [debug] GET "/".
[Thu Sep 18 20:47:12 2014] [debug] Rendering template "index.html.ep" from
DATA section.
[Thu Sep 18 20:47:12 2014] [debug] 200 OK (0.007622s, 131.199/s).
[Thu Sep 18 20:47:12 2014] [debug] GET "/title".
[Thu Sep 18 20:47:12 2014] [debug] Routing to a callback.
[Thu Sep 18 20:47:12 2014] [debug] 101 Switching Protocols (0.000556s,
1798.561/s).
[Thu Sep 18 20:47:12 2014] [debug] Retrieved title from URL
http://mojolicio.us:
Mojolicious - Perl real-time web framework
The example shows a simple web-socket powered Mojolicious application
serving the index page with a template and providing a web socket server.
Your browser will first render an empty index page and open a websocket
application to retrieve the content, which in turn will be retrieved by the
application from the mojolicio.us website.
Cheers
+rl
--
Roland Lammel
QuikIT - IT Lösungen - flexibel und schnell
Web: http://www.quikit.at
Phone: +43 (676) 9737845
Email: [email protected]
"Enjoy your job, make lots of money, work within the law. Choose any two."
On Thu, Sep 18, 2014 at 8:06 PM, sri <[email protected]> wrote:
> which makes a non-blocking GET request
>>>
>>
> This is not quite correct btw., the example performs a blocking GET
> request.
>
> --
> sebastian
>
> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.