Guest User

Untitled

a guest
Apr 24th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. use strict;
  2. use Plack::Builder;
  3.  
  4. my $body;
  5. $body .= qq(<script src="/js/hello_) . rand(1) . qq(.js"></script>\n) for 1..10;
  6. $body .= qq(<link rel="stylesheet" href="/css/hello_) . rand(1) . qq(.css"/>\n) for 1..10;
  7. $body .= qq(<body onload="alert('page is loaded')">Hello</body>);
  8.  
  9. my $page = sub {
  10. return [ 200, [ 'Content-Type' => 'text/html' ], [ $body ] ];
  11. };
  12.  
  13. my $js = sub {
  14. my $env = shift;
  15. return [ 200, [ 'Content-Type' => 'text/html' ], [ qq(var t="$env->{PATH_INFO}";) ] ];
  16. };
  17.  
  18. my $css = sub {
  19. return [ 200, [ 'Content-Type' => 'text/html' ], [ "body { font-size: 100px }" ] ];
  20. };
  21.  
  22. builder {
  23. mount "/js" => $js;
  24. mount "/css" => $css;
  25. mount "/" => $page;
  26. };
Add Comment
Please, Sign In to add comment