Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Simple http server one-liner for some static files?

by Ea (Friar)
on Jan 17, 2013 at 17:31 UTC ( #1013830=note: print w/ replies, xml ) Need Help??


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?


Comment on Re^2: Simple http server one-liner for some static files?
Download Code
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...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1013830]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2015-07-06 14:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (75 votes), past polls