HttpD On-Demand

Every so often I have a need to debug static web content which is usually within a random directory on my development system. I've created an alias in Linux which uses Python to start an HTTP daemon which serves static HTML content from the CWD (current working directory).

This alias uses Python and a core library to start an http daemon with directory browsing enabled. Very handy.

alias httpd='python -m SimpleHTTPServer'

Being a Perlist, I figured there is probably a way to do this in Perl, but after a few searches and lame attempts at it myself, I haven't been able to figure it out.

The closest I've gotten, after more research than this is worth, was starting the Mojolicious daemon and setting the MOJO_HOME envvar, which doesn't work.

MOJO_HOME=$(pwd) mojo daemon

Having bounced around various web frameworks and documentation, I've finally landed on Plack::App::Directory which does exactly what I'm after, with a little arm twisting.

plackup -MPlack::App::Directory -e 'Plack::App::Directory->new->to_app'


Thanks for sharing this useful tips. I has copied that into my .bashrc.

Hm, this has got to be at least the second or third time someone posted about this recently on bpo...

There's an app for that (R), BTW: (although I really prefer typing "httpthis" instead of "http_this").

Also, I remember that Redhat/CentOS used to have Apache webserver installed as 'httpd'.

Leave a comment

About Al Newkirk

user-pic ... proud Perl hacker, ask me anything!