Skip to content

Instantly share code, notes, and snippets.

@hiroaki
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hiroaki/d66243094dd587990adc to your computer and use it in GitHub Desktop.
Save hiroaki/d66243094dd587990adc to your computer and use it in GitHub Desktop.
Publish directory via HTTP using plack
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Std;
my $opts = {
s => 'Standalone',
h => '0.0.0.0',
p => 5000,
d => '.',
t => 60,
};
{
local $SIG{__WARN__} = sub { die "$@" };
getopts('d:h:p:s:t:', $opts);
};
my $engine = $opts->{s};
my $host = $opts->{h};
my $dir = $opts->{d};
my $port = $opts->{p};
my $timeout = $opts->{t};
exec 'plackup', '-s', $engine, '--host', $host, '--port', $port,
'-e', "use Plack::App::Directory; Plack::App::Directory->new({root=>'$dir'})->to_app";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment