Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use Mojolicious::Lite;
  3.  
  4. # Documentation browser under "/perldoc"
  5. plugin 'PODRenderer';
  6.  
  7. get '/' => sub {
  8. my $self = shift;
  9. my $value = $self->cookie('foo');
  10. $value++;
  11. $self->stash( value => $value );
  12. $self->cookie('foo' => $value );
  13. if ( $value > 3 ) {
  14. $self->cookie('foo', { expires => time - 1 } );
  15. }
  16. $self->render('index');
  17. };
  18.  
  19. app->start;
  20. __DATA__
  21.  
  22. @@ index.html.ep
  23. % layout 'default';
  24. % title 'Welcome';
  25. Welcome to the Mojolicious real-time web framework!
  26.  
  27. Cookie Value <%= $value %>
  28.  
  29. @@ layouts/default.html.ep
  30. <!DOCTYPE html>
  31. <html>
  32. <head><title><%= title %></title></head>
  33. <body><%= content %></body>
  34. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement