gpt4 book ai didi

perl - Mojolicious -> 路线的初学者问题

转载 作者:行者123 更新时间:2023-12-02 01:55:27 24 4
gpt4 key购买 nike

以下示例代码来自 http://mojolicio.us/当前在 morbo 下运行在 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 %>

但是路线没有按预期工作:

enter image description here

谁能告诉我,我在这里犯了哪个愚蠢的错误?

调试输出:

[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.

最佳答案

好的,感谢 irc.perl.org; #mojo 我现在找到了原因:导致无法找到模板的前导空格,删除它们后,它现在可以工作了!结案了!

关于perl - Mojolicious -> 路线的初学者问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20372388/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com