Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@afresh1
Last active June 4, 2023 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afresh1/f1720f75b3d52ac8f643 to your computer and use it in GitHub Desktop.
Save afresh1/f1720f75b3d52ac8f643 to your computer and use it in GitHub Desktop.
A Mojolicious One Liner to serve static files from the current directory
#!/bin/sh
exec perl -Mojo -E '$m=a("/");$m->static->paths(["."]);$m->start' daemon
@briandfoy
Copy link

A modern (2021) version uses Mojolicious::Plugin::Directory (separate install):

$ perl -Mojo -MCwd=getcwd -E 'a->plugin("Directory", root => getcwd())->start' daemon

@afresh1
Copy link
Author

afresh1 commented Dec 1, 2021

Fancy! Also a choice is this one with Plack::App::Directory that ships with Plack and uses plackup from there as well.

#!/bin/sh
exec plackup -MPlack::App::Directory -e 'Plack::App::Directory->new' "$@"

@briandfoy
Copy link

Now there is also

$ perl -Miniweb

from Mojolicious::Plugin::DirectoryServer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment