February 2016 Archives

Simplest way of serving local files over HTTP?

I've always admired Python's way of serving local files by simply doing:

$ python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...

And I've been wondering if there's a way to achieve the same in Perl without requiring lots of dependencies from CPAN. This morning I just came out with this:

$ perl -Mojo -E 'a->static->paths(["."]);a->start' daemon
Server available at http://127.0.0.1:3000

It shows the file content, though it doesn't show the directory listing.

Is there any simpler way?…

About Alex Muntada

user-pic I love Perl.