http://www.perlmonks.org?node_id=1013830


in reply to Re: Simple http server one-liner for some static files?
in thread Simple http server one-liner for some static files?

Better 2 years late, than never. :)

The only problem with having gadzillions of programs is finding the right one for you. The poster was looking for this:

http_this

which didn't make the first 2 pages of results. Written 3 months earlier than the question, it's just a wrapper around the Plack::App::Directory which was suggested in another thread, but it's simpler, like the python command in a book on D3 that sent me looking for the perl equivalent of python -m SimpleHTTPServer

perl -e 'print qq(Just another Perl Hacker\n)' # where's the irony switch?

Replies are listed 'Best First'.
Re^3: Simple http server one-liner for some static files?
by Anonymous Monk on Dec 31, 2014 at 01:39 UTC
    Joining the "better late than never"-motto, here a (long) one-liner which—in constrast to the answers before—does not require non-core modules:
    perl -MHTTP::Daemon -e '$d = HTTP::Daemon->new(LocalPort => 8000) or +die $!; while ($c = $d->accept) { while ($r = $c->get_request) { +$c->send_file_response(".".$r->url->path) } }'
    Actually this is a flattened and slightly modified version of HTTP::Daemon's synopsis section.
      Update to Re^3: After a short investigation with corelist HTTP::Daemon turns out that HTTP::Daemon is not a core-module. I confused that since my fresh installed Debian distribution already came along with that module...