Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Mojolicious::Lite;
- use Mojo::UserAgent;
- use Modern::Perl;
- get '/' => sub {
- # get this to render the hello tempalte
- my $ua = Mojo::UserAgent->new;
- my $self = shift;
- # my $name =
- # $ua->get(
- #'http://api.powerhousemuseum.com/api/v1/category/xml/?api_key=8fbb61ea34d6f5d'
- # )->res->dom->find('result categories category:first-child name');
- # $self->render( 'hello', name => $name );
- my $names = $ua
- ->get('http://api.powerhousemuseum.com/api/v1/category/xml/?api_key=8fbb61ea34d6f5d')->res->dom->result->categories;
- #->res->dom
- #->result->categories->category->name;
- $self->stash(name => $names);
- $self->render('hello');
- };
- #start the application
- app->start;
- ## the rest of the file will be a template for markup
- ## Hello template:
- __DATA__
- @@ layouts/wrapper.html.ep
- <h1><%= title %></h1>
- <%= content %> this is the layout wrapper<br>
- % for my $name (@$names) {
- <li>
- $name
- </li>
- % }
- </ul>
- @@ hello.html.ep
- <h1>YO againnnnnn</h1>
- <%= $name %>
- <br>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement