| 1 | package iniweb; | ||
| 2 | |||
| 3 | use feature ':5.16'; | ||
| 4 | use ojo; | ||
| 5 | |||
| 6 | sub import { | ||
| 7 | $ENV{PERL_MINIWEB_ROOT} //= '.'; | ||
| 8 | $ENV{PERL_MINIWEB_DIR_INDEX} //= 'index.html:index.htm'; | ||
| 9 | |||
| 10 | local @ARGV = 'daemon'; | ||
| 11 | my %opts = ( | ||
| 12 | root => $ENV{PERL_MINIWEB_ROOT}, | ||
| 13 | dir_index => [ split ':', $ENV{PERL_MINIWEB_DIR_INDEX} ], | ||
| 14 | ); | ||
| 15 | plugin( DirectoryServer => %opts )->start; | ||
| 16 | |||
| 17 | exit( 0 ); | ||
| 18 | } | ||
| 19 | |||
| 20 | 1; | ||
| 21 | |||
| 22 | =head1 NAME | ||
| 23 | |||
| 24 | iniweb - Very quickly spawn a web server | ||
| 25 | |||
| 26 | =head1 SYNOPSIS | ||
| 27 | |||
| 28 | perl -Miniweb | ||
| 29 | |||
| 30 | =head1 DESCRIPTION | ||
| 31 | |||
| 32 | The command in the synopsis will spawn a web server, serving static files | ||
| 33 | from the current working directory. | ||
| 34 | |||
| 35 | =head2 Environment Variables | ||
| 36 | |||
| 37 | =over | ||
| 38 | |||
| 39 | =item C<PERL_MINIWEB_ROOT> | ||
| 40 | |||
| 41 | Root directory to serve. Defaults to the current directory. | ||
| 42 | |||
| 43 | =item C<PERL_MINIWEB_DIR_INDEX> | ||
| 44 | |||
| 45 | Colon-seperated list of filenames to treat as a directory index. Defaults to | ||
| 46 | C<< "index.html:index.htm" >>. | ||
| 47 | |||
| 48 | =back | ||
| 49 | |||
| 50 | =head1 AUTHOR | ||
| 51 | |||
| 52 | Toby Inkster E<lt>tobyink@cpan.orgE<gt>. | ||
| 53 | |||
| 54 | =head1 SEE ALSO | ||
| 55 | |||
| 56 | L<Mojolicious::Plugin::DirectoryServer> | ||
| 57 | |||
| 58 | =head1 LICENSE | ||
| 59 | |||
| 60 | This library is free software; you can redistribute it and/or modify | ||
| 61 | it under the same terms as Perl itself. | ||
| 62 | |||
| 63 | =cut |