Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Mojolicious::Lite;
- use Data::Dumper;
- get '/' => 'index';
- get '/another-action' => 'another-template';
- ###############################
- # Adds a new node to the tree #
- ###############################
- post '/new' => sub {
- my $self = shift;
- my $num = $self->param('num');
- $self->flash( error => "Parent node not found" ) if $num < 10;
- # I got some problems here with Flash, so I did in an alternative way
- #$self->stash->{'mojo.session'}->{flash}->{error} = "error comes here";
- #app->log->info( Dumper ( $self->stash->{'mojo.session'} ) );
- #app->log->info( Dumper ( $self->flash("error") ) );
- # Redirects to Tree listing page
- $self->redirect_to('/another-action');
- };
- app->start;
- __DATA__
- @@ another-template.html.ep
- %= flash 'error'
- @@ index.html.ep
- <form action='/new' method='post'>
- Type a number bigger then 10:
- <input type='text' name='num' size='5'/>
- <span class='error'>Erro: <%= flash 'error' %></span>
- <input type='submit' value='Check'/>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement