NOThing Is Impossible! —— 原创文章,谢绝转载!
主页: http://dancer.sukria.net/
作者: sukria,是日本某公司的CTO,知名CPANer
创意: 来自于Ruby的一个框架Sinatra
例子:
| #!/usr/bin/perl use Dancer; get '/hi' => sub { "Hello World!" }; dance; |
然后就可以独立运行了:
| $ perl ./hi.pl >> Listening on 127.0.0.1:3000 == Entering the dance floor ... == GET /hi HTTP/1.0 200 OK |
在浏览器里输入 http://your_host:3000/hi/就可以看到Helloworld字样了。默认端口是3000.
这是作者主页的整个代码:
| #!/usr/bin/perl use Dancer; use Template; my @pages = qw(quickstart documentation contribute about example); get '/' => sub { template 'home'; }; get '/:page' => sub { my ($page) = params->{page}; pass and return false unless grep /$page/, @pages; template $page; }; get '/*' => sub { status 'not_found'; template 'not_found'; }; dance; |
优势:
问题:
我试用了一下,用simple模板可以,用TT的没有用,页面是空白,哪位用过指点下。
欢迎大家都来用。
You can be the first to comment!