Skip to content

Instantly share code, notes, and snippets.

@mugifly

mugifly/daemon.pl

Created Jan 23, 2013
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@mugifly 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
You can’t perform that action at this time.