[debug] GET "/" [debug] Routing to a callback [debug] 200 OK (0.007915s, 126.342/s) [debug] GET "/get_status" #### #!/usr/bin/perl use Mojolicious::Lite; plugin 'HTMLTemplateProRenderer'; use Mojo::JSON qw(decode_json encode_json); use HTML::Template; use Data::Dump 'pp'; # dbh attribute app->attr(dbh => sub { my $c = shift; # I set a connection to the DB my $dbh = ...; # Passing connections in a hashref my $pass_dbh = {'dbh' => $dbh }; return $pass_dbh; }); any '/' => sub { my $c = shift; # Load Main Template $c->render( template => 'main', ); # Cant get this to show on the main template. $c->stash( title => ' This is the text for the title' ); }; get '/get_status' => sub { my $c = shift; my $get_update = $c->req->query_params->param('update'); # SQL goes here - this code is only for showing my logic my $data = (<render( template => 'main', ); # this is the tag in the template $c->stash( result => ' This is the result for testing' ); # I also return json from the sql query results, called from ajax # and it works fine. return $c->render(json => $data ); }; app->start;