-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample
executable file
·46 lines (37 loc) · 983 Bytes
/
sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env perl
use Mojolicious::Lite;
# /foo?user=sri
get '/foo' => sub {
my $self = shift;
my $user = $self->param('user');
my $id = $self->param('id');
$self->render(text => "Hello $user. Your id is $id.");
};
get '/' => sub {
my $self = shift;
my $name = $self->param('name');
$self->stash(name => $name);
$self->render('index');
};
get '/agent' => sub {
my $self = shift;
my $host = $self->req->url->to_abs->host;
my $ua = $self->req->headers->user_agent;
$self->res->headers->header('X-Bender' => 'This is my own herder');
$self->render(text => "Request by $ua reached $host.");
};
app->start;
__DATA__
@@ index.html.ep
% layout 'default';
% title 'This is the title!';
Mojoliciousへようこそ!
<div>divではさむと</div>
<p><strong>ここはstrong</strong></p>
<div>nameの値: <%= $name %> 左にnameの値</div>
@@ layouts/default.html.ep
<!DOCTYPE html>
<html>
<head><title><%= title %></title></head>
<body><%= content %></body>
</html>