-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlil_app
64 lines (51 loc) · 990 Bytes
/
lil_app
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!perl
use strict;
use warnings;
use Mojolicious::Lite;
$ENV{MOJO_LOG_LEVEL} = 'debug';
get '/' => sub {
my ( $c ) = @_;
return $c->render;
};
get '/login' => sub {
my ( $c ) = @_;
$c->stash( 'logged_in' => 0 );
if ( my $user = $c->param( "username" ) ) {
if ( my $password = $c->param( "password" ) ) {
if ( $password eq 'letmein' ) {
$c->stash( 'logged_in' => 1 );
}
}
}
return $c->render;
};
app->start;
__DATA__
@@ .html.ep
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<a href="/login">Login</a>
</body>
</html>
@@ login.html.ep
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<% if ( $logged_in ) { %>
Welcome!
<% } else { %>
<form action="/login">
Username: <input name="username" /><br />
Password: <input name="password" type="password" /><br />
<button name="submit" value="Login" title="Login" type="submit" >Login</button>
</form>
<% } %>
</body>
</html>