Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by sundialsvc4 (Monsignor)
on Oct 14, 2010 at 01:48 UTC ( #865186=note: print w/ replies, xml ) Need Help??


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

Yes, Python has quite a few excellent web-server programs ... and Perl has gadzillions.   Just surf over to http://search.cpan.org, search for “HTTP server,” and you’ll see what I mean.

If you search instead for HTTP::Server, you’ll see some of the most readily-available packages, such as HTTP::Server::Simple and my latest personal favorite, HTTP::Server::Brick.

Each of these are very comparable to the Python package you cited.   “You got a simple job to do, and you want a simple way to do it.”   Done.


Comment on Re: Simple http server one-liner for some static files?
Re^2: Simple http server one-liner for some static files?
by Anonymous Monk on Oct 14, 2010 at 02:42 UTC

    Hi, yes, I found those -- thank you. Unfortunately, neither of those modules show in their Synopses how to use them to run an http server as a one-liner. If you know how to use either to do that, could you please share?

      stick with what works

      It's not difficult. The "-Mxxx" option to perl loads module "xxx" and "-e" lets you supply an expression to evaluate (a command)

      perl -MHTTP::Server::Brick -e '$s=HTTP::Server::Brick->new(port=>8080); $s->mount("/"=>{path=>"/tmp"}); $s->start'

      This serves /tmp and its sub-directories, if you don't want that you'll want wildcard=>0 as well as the path.

Re^2: Simple http server one-liner for some static files?
by Ea (Friar) on Jan 17, 2013 at 17:31 UTC
    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?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2014-07-30 18:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (239 votes), past polls