今更ながらMojoliciousはじめました。(インストール編)
2013年4月4日
今まではCatalystを触っていたんですが、少しずつMojoliciousも触ってみようと思います。
(次に何か作る時は、Mojolicious使うと思いま)
インストール
公式Mojolicious – Perl real-time web frameworkを参考にまずは、下記コマンドでインストール。
$ curl get.mojolicio.us | sh
アプリの作成(Mojolicious::Lite)
mojo generate lite_app my_app.pl
これで、my_app.plが作成されました。
perl my_app.pl daemon
デフォルトはポート3000番で起動したみたいですね。
IP直打ちで確認してみます。
<!DOCTYPE html> <html> <head><title>Welcome</title></head> <body>Welcome to the Mojolicious real-time web framework! </body> </html>
動いたぽい。
アプリの作成(Mojo)
mojo generate app MyApp
今度は、ファイルが沢山作られました。
$ tree my_app
my_app
├── lib
│ ├── MyApp
│ │ └── Example.pm
│ └── MyApp.pm
├── log
├── public
│ └── index.html
├── script
│ └── my_app
├── t
│ └── basic.t
└── templates
├── example
│ └── welcome.html.ep
└── layouts
└── default.html.ep
とりあえず起動してみます。
$ perl script/my_app daemon
で、アクセス。
<!DOCTYPE html> <html> <head><title>Welcome</title></head> <body><h2>Welcome to the Mojolicious real-time web framework!</h2> This page was generated from the template "templates/example/welcome.html.ep" and the layout "templates/layouts/default.html.ep", <a href="/">click here</a> to reload the page or <a href="/index.html">here</a> to move forward to a static page. </body> </html>
動いてるぽい。