Mojo_1_第一个简单例子
Posted FireC@t @ Perl6
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mojo_1_第一个简单例子相关的知识,希望对你有一定的参考价值。
1 use Mojolicious::Lite; 2 3 #根目录,Get方法打开 4 #正接显示文本text 5 get ‘/‘ => sub{ 6 my $service = shift; 7 $service->render(text => ‘Hello, world!‘); 8 }; 9 10 get ‘/login‘ => sub{ 11 #pass 12 }; 13 #/login路径用get打开, 如果没找到s"ub函数"(方法) 14 #会用默认的模板打开, 如果默认的模板也没有就会超时404 15 16 app->start; 17 18 # output: 19 # C:\mojo>morbo ./myapp.pl 20 # Server available at http://127.0.0.1:3000 21 # [Sun Feb 26 08:45:56 2017] [debug] GET "/" 22 # [Sun Feb 26 08:45:56 2017] [debug] Routing to a callback 23 # [Sun Feb 26 08:45:56 2017] [debug] 200 OK (0.000942s, 1061.571/s) 24 # [Sun Feb 26 08:46:00 2017] [debug] GET "/login" 25 # [Sun Feb 26 08:46:00 2017] [debug] Routing to a callback 26 # [Sun Feb 26 08:46:00 2017] [debug] Template "login.html.ep" not found 27 # [Sun Feb 26 08:46:00 2017] [debug] Nothing has been rendered, expecting delayed response 28 # [Sun Feb 26 08:46:15 2017] [debug] Inactivity timeout 29 # [Sun Feb 26 08:46:15 2017] [debug] GET "/login" 30 # [Sun Feb 26 08:46:15 2017] [debug] Routing to a callback 31 # [Sun Feb 26 08:46:15 2017] [debug] Template "login.html.ep" not found 32 # [Sun Feb 26 08:46:15 2017] [debug] Nothing has been rendered, expecting delayed response
可以这样运行:
morbo script.pl
以上是关于Mojo_1_第一个简单例子的主要内容,如果未能解决你的问题,请参考以下文章