来自http://mojolicio.us/的以下示例代码目前正在http://62.113.243.155/
use Mojolicious::Lite;
# Simple plain text response
get '/' => {text => 'I ♥ Mojolicious!'};
# Route associating "/time" with template in DATA section
get '/time' => 'clock';
# RESTful web service with JSON and text representation
get '/list/:offset' => sub {
my $self = shift;
my $numbers = [0 .. $self->param('offset')];
$self->respond_to(
json => {json => $numbers},
txt => {text => join(',', @$numbers)}
);
};
# Scrape information from remote sites
post '/title' => sub {
my $self = shift;
my $url = $self->param('url') || 'http://mojolicio.us';
$self->render(
text => $self->ua->get($url)->res->dom->at('title')->text);
};
# WebSocket echo service
websocket '/echo' => sub {
my $self = shift;
$self->on(message => sub {
my ($self, $msg) = @_;
$self->send("echo: $msg");
});
};
app->start;
__DATA__
@@ clock.html.ep
% use Time::Piece;
% my $now = localtime;
The time is <%= $now->hms %>
但路线没有按预期运作:
任何人都可以告诉我,我在这里做了哪个愚蠢的错误?
调试输出:
[Wed Dec 4 10:34:26 2013] [debug] GET "/".
[Wed Dec 4 10:34:26 2013] [debug] 200 OK (0.000559s, 1788.909/s).
[Wed Dec 4 10:34:37 2013] [debug] GET "/time".
[Wed Dec 4 10:34:37 2013] [debug] Template "clock.html.ep" not found.
[Wed Dec 4 10:34:37 2013] [debug] Template "not_found.development.html.ep" not found.
答案 0 :(得分:2)
好的,感谢irc.perl.org; #mojo我现在找到了原因:导致空格导致无法找到模板,删除后,它现在可以正常工作了!结案!