Skip to content

Instantly share code, notes, and snippets.

@mfontani
Created September 18, 2015 10:27
Show Gist options
  • Save mfontani/05d38fdfa08351d7ab34 to your computer and use it in GitHub Desktop.
Save mfontani/05d38fdfa08351d7ab34 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use Mojolicious::Lite;
get '/' => sub {
my $c = shift;
$c->render( template => 'index' );
};
get '/*' => sub {
my $c = shift;
return $c->render(template => '502', status => 502 )
if $c->req->url->path =~ /502/;
$c->render(template => 'index');
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'Welcome';
This page is working! Look ma, no <tt>502</tt>s!
@@ 502.html.ep
OH NOES! THIS 502ed!
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment