Initial commit

This commit is contained in:
2026-07-30 17:26:40 -07:00
commit 914c0374e4
11 changed files with 203 additions and 0 deletions

20
mojo_app/lib/MojoApp.pm Normal file
View File

@@ -0,0 +1,20 @@
package MojoApp;
use Mojo::Base 'Mojolicious', -signatures;
# This method will run once at server start
sub startup ($self) {
# Load configuration from config file
my $config = $self->plugin('NotYAMLConfig');
# Configure the application
$self->secrets($config->{secrets});
# Router
my $r = $self->routes;
# Normal route to controller
$r->get('/')->to('Example#welcome');
}
1;

View File

@@ -0,0 +1,11 @@
package MojoApp::Controller::Example;
use Mojo::Base 'Mojolicious::Controller', -signatures;
# This action will render a template
sub welcome ($self) {
# Render template "example/welcome.html.ep" with message
$self->render(msg => 'Welcome to the Mojolicious real-time web framework!');
}
1;

3
mojo_app/mojo_app.yml Normal file
View File

@@ -0,0 +1,3 @@
---
secrets:
- EVSQKfOiLasBIiDnsmldafRdgOn4aB4lPa9m4KNjc7w_wKCN_6YdQtfWswvXHOTLZVK3yz5Dg9_xMF-XKUnuB0hQmGztMo1-9aJrOW-4n7PioUGef-DzpRt1Da6l4tCLHsvwzQ7xd0ya2v6Mszh4lLbSEEdptlQAiRe1esWb4QU

View File

@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>Welcome to the Mojolicious real-time web framework!</title>
</head>
<body>
<h2>Welcome to the Mojolicious real-time web framework!</h2>
This is the static document "public/index.html",
<a href="/">click here</a> to get back to the start.
</body>
</html>

11
mojo_app/script/mojo_app Executable file
View File

@@ -0,0 +1,11 @@
#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::File qw(curfile);
use lib curfile->dirname->sibling('lib')->to_string;
use Mojolicious::Commands;
# Start command line interface for application
Mojolicious::Commands->start_app('MojoApp');

9
mojo_app/t/basic.t Normal file
View File

@@ -0,0 +1,9 @@
use Mojo::Base -strict;
use Test::More;
use Test::Mojo;
my $t = Test::Mojo->new('MojoApp');
$t->get_ok('/')->status_is(200)->content_like(qr/Mojolicious/i);
done_testing();

View File

@@ -0,0 +1,9 @@
% layout 'default';
% title 'Welcome';
<h2><%= $msg %></h2>
<p>
This page was generated from the template "templates/example/welcome.html.ep"
and the layout "templates/layouts/default.html.ep",
<%= link_to 'click here' => url_for %> to reload the page or
<%= link_to 'here' => '/index.html' %> to move forward to a static page.
</p>

View File

@@ -0,0 +1,5 @@
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>