Skip to content

Instantly share code, notes, and snippets.

@mugifly
Created January 23, 2013 16:50
Show Gist options
  • Save mugifly/4609696 to your computer and use it in GitHub Desktop.
Save mugifly/4609696 to your computer and use it in GitHub Desktop.
How to use the Morbo (include Mojolicious) as a simple http daemon. For example, it will be useful for doing development with XMLHTTPRequest(Javascript) on localhost.
#!/usr/bin/env perl
use Mojolicious::Lite;
push @{app->static->paths}, 'site/'; # File path
app->start('daemon');
# Execute this script on terminal: perl daemon.pl
# Then, let's access to http://localhost:3000/***
@mugifly
Copy link
Author

mugifly commented Aug 19, 2013

コマンドとして呼び出せるようにして、

push @{app->static->paths}, '.'; # File path

のようにカレントディレクトリを指すようにしておけば、コマンドを打つだけでサッとHTTPアクセスできるようになります。
(※index.htmlなどでもファイル名を入力しないと、404Errorになるので注意。)

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