3

以下来自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 %>

但路线没有按预期工作:

在此处输入图像描述

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

调试输出:

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

1 回答 1

2

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

于 2013-12-04T18:30:53.333 回答