line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
608
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
3
|
|
|
|
|
|
|
package App::SimpleHTTPServer; |
4
|
|
|
|
|
|
|
$App::SimpleHTTPServer::VERSION = '0.002'; |
5
|
|
|
|
|
|
|
# ABSTRACT: Serve up a directory via http simply and easily |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
22
|
BEGIN { @ARGV = qw/ -m production /; } |
8
|
1
|
|
|
1
|
|
540
|
use Mojolicious::Lite; |
|
1
|
|
|
|
|
100229
|
|
|
1
|
|
|
|
|
6
|
|
9
|
1
|
|
|
1
|
|
15285
|
use Scalar::Util qw/ looks_like_number /; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
265
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $TESTING = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
1
|
|
|
1
|
|
341
|
my $package = shift; |
15
|
1
|
|
|
|
|
1
|
my $port = shift; |
16
|
1
|
50
|
|
|
|
7
|
if (not looks_like_number $port) { |
17
|
1
|
50
|
|
|
|
3
|
unshift @_, $port if defined $port; |
18
|
1
|
|
|
|
|
1
|
$port = 8000; |
19
|
|
|
|
|
|
|
} |
20
|
1
|
|
|
|
|
1
|
my $path = shift; |
21
|
1
|
50
|
|
|
|
3
|
$path = '.' unless defined $path; |
22
|
|
|
|
|
|
|
|
23
|
1
|
|
|
|
|
1
|
push @{ app->renderer->classes }, __PACKAGE__; |
|
1
|
|
|
|
|
4
|
|
24
|
1
|
|
|
|
|
43
|
push @{ app->static->classes }, __PACKAGE__; |
|
1
|
|
|
|
|
3
|
|
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
35
|
plugin 'Directory::Stylish' => root => $path; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my @args = (qw/ daemon -l /, "http://*:$port/"); |
29
|
0
|
0
|
|
|
|
|
@args = (qw/ eval /) if $TESTING; # For testing, it needs something to |
30
|
|
|
|
|
|
|
# do so it doesn't display help message |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
app->secrets([qw/ foo /]); |
33
|
0
|
|
|
|
|
|
app->start(@args); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
1; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=pod |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=encoding UTF-8 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 NAME |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
App::SimpleHTTPServer - Serve up a directory via http simply and easily |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 VERSION |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
version 0.002 |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SYNOPSIS |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$ # To serve the current directory via http on port 8000, simply do: |
53
|
|
|
|
|
|
|
$ perl -MApp::SimpleHTTPServer |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$ # or use the serve_dir script: |
56
|
|
|
|
|
|
|
$ serve_dir |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SEE ALSO |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
L - The Mojolicious web framework |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
L - The module that actually renders |
63
|
|
|
|
|
|
|
the directory listing |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Andreas Guldstrand |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This software is Copyright (c) 2015 by Andreas Guldstrand. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This is free software, licensed under: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
The MIT (X11) License |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__DATA__ |