Plack とは
Apache、nginx などのアプリケーションサーバーと、Amon2、Catalyst などのウェブアプリケーションフレームワーク間を取り持つインターフェースで、Python でいう WSGI、Ruby でいう Rack。
インストール
$ cpanm Task::Plack
CPAN Plack に付属しているスタンドアロン PSGIサーバ(HTTP::Server::PSGI)で PSGI アプリケーションを起動できる。
PSGI ファイルを plackup で起動する
PSGI: test.psgi
use strict; use warnings; my $app = sub { my $env = shift; return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ]; };
$ plackup test.psgi
ブラウザで http://localhost:5000/ を開くと、「Hello World」が表示されます。
ポートを変更する場合
$ plackup --port8080 test.psgi