Mojolicious::LiteのスクリプトをCGIで動かす
以下のスクリプトをtest.plという名前で保存します。
#!/usr/pkg/bin/perl use lib '../lib'; use Mojolicious::Lite; get '/' => 'index'; get '/info' => sub { my $self = shift; $self->render(text => 'info page.'); }; shagadelic('cgi'); __DATA__ @@ index.html.eplite <html> <head><title>Test</title></head> <body>Mojolicious::Lite test.</body> </html>
WebサーバがApacheの場合、CGIとして起動する際には
http://localhost/~hiramatsu/test.pl
では「get '/'」がマッチせず「File not found.」が表示されます。
http://localhost/~hiramatsu/test.pl/
と最後にスラッシュ(/)を付加すると「get '/'」が呼び出されます。infoは
http://localhost/~hiramatsu/test.pl/info
でも大丈夫。