Beginner problems with Mojolicious -> routes

663 views Asked by At

Following example code from http://mojolicio.us/ is currently running under morbo at 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 %>

But the routes aren't working as expected:

enter image description here

Could anyone maybe tell me, which stupid mistake I'm doing here?

Debug output:

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

There are 1 answers

0
royskatt On BEST ANSWER

Ok, thanks to irc.perl.org; #mojo I found now the reason: leading whitespaces caused, that the template couldn't been found, after removing them, it now works! Case closed!