Created
October 20, 2016 11:55
-
-
Save brianmed/731f72ee6c7d4857d994479b17d32b00 to your computer and use it in GitHub Desktop.
Shared logic in mojolicious lite app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite; | |
require SharedPkg; | |
get '/' => sub { | |
my $c = shift; | |
$c->render(template => 'index', joy => $SharedPkg::variable); | |
}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
<!DOCTYPE html> | |
<html> | |
<head><title>News</title></head> | |
<body>Admin: <%= $joy %></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite; | |
require SharedPkg; | |
get '/' => sub { | |
my $c = shift; | |
$c->render(template => 'index', joy => $SharedPkg::variable); | |
}; | |
app->start; | |
__DATA__ | |
@@ index.html.ep | |
<!DOCTYPE html> | |
<html> | |
<head><title>News</title></head> | |
<body>News: <%= $joy %></body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Mojolicious::Lite; | |
plugin Mount => {'127.0.0.1/news' => './app_news.pl'}; | |
plugin Mount => {'127.0.0.1/admin' => './app_admin.pl'}; | |
get '/' => sub { | |
my $c = shift; | |
$c->render(text => "Hello"); | |
}; | |
app->start; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment