Questions tagged [mojolicious]

Mojolicious is an MVC web framework in Perl.

Back in the early days of the web there was this wonderful Perl library called CGI, many people only learned because of it. It was simple enough to get started without knowing much about the language and powerful enough to keep you going, learning by doing was much fun. While most of the techniques used are outdated now, the idea behind it is not. Mojolicious is a new attempt at implementing this idea using state of the art technology.

Features An amazing web framework supporting a simplified single file mode through Mojolicious::Lite. Powerful out of the box with RESTful routes, plugins, Perl-ish templates, session management, signed cookies, testing framework, static file server, I18N, first class unicode support and much more for you to discover.

Features

  • An amazing MVC web framework supporting a simplified single file mode through Mojolicious::Lite. Powerful out of the box with RESTful routes, plugins, Perl-ish templates, session management, signed cookies, testing framework, static file server, I18N, first class unicode support and much more for you to discover.
  • Very clean, portable and Object Oriented pure Perl API without any hidden magic and no requirements besides Perl 5.8.7.

  • Full stack HTTP 1.1 and WebSocket client/server implementation with IPv6, TLS, Bonjour, IDNA, Comet (long polling), chunking and multipart support.

  • Builtin async IO web server supporting epoll, kqueue, UNIX domain sockets and hot deployment, perfect for embedding.

  • Automatic CGI, FastCGI and PSGI detection.

  • JSON and XML/HTML5 parser with CSS3 selector support.

  • Fresh code based upon years of experience developing Catalyst.

Resources and links

672 questions
8
votes
2 answers

How to use my own subroutines (globally) in a Mojolicious::Lite Application

I need to be able to write and call my own subroutines in a Mojolicious::Lite Application. However, the intuitive way to do this doesn't seem to be working. I emailed a colleague who has more Mojolicious experience than I do with this question and…
kingsfoil
  • 3,795
  • 7
  • 32
  • 56
8
votes
1 answer

How to fix the Mojolicious-Boilerplate app?

Today I started to learn the Mojolicious framework. IMHO, the best way is "learn by examples", so study some "already done" application a play with it. Therefore I downloaded the Mojolicious-Boilerplate, what should be a demo of Mojolicious and…
kobame
  • 5,766
  • 3
  • 31
  • 62
8
votes
2 answers

How can I get the port that Mojolicious::Lite chooses?

Joel Berger posted this little program to start a web server to serve local files, and it works great: use Mojolicious::Lite; @ARGV = qw(daemon); use Cwd; app->static->paths->[0] = getcwd; any '/' => sub { shift->render_static('index.html'); …
brian d foy
  • 129,424
  • 31
  • 207
  • 592
7
votes
2 answers

Passing arguments to redirect_to in mojolicious and using them in the target controller

I am passing arguments to redirect_to like $c->redirect_to('named', foo => 'bar'); or $c->redirect_to('named, query => {foo=> 'bar'}); but I am not sure how to use it or retrieve the value of foo in the target controller.
PMat
  • 2,039
  • 2
  • 29
  • 46
7
votes
2 answers

Example for several (fastcgi/uwsgi/scgi/proxy_pass) Mojolicious apps in the same nginx virtual host?

I have some Mojolicious-based apps which happily run under Apache2 with mod_cgi and mod_fastcgi. The urls are for example: http://example.org/oneapp/path/info?foo=bar http://example.org/oneapp?foo=bar …
Беров
  • 1,383
  • 10
  • 22
7
votes
1 answer

What "ladder sub {...}" means in perl?

I'm reading tweetylicious source from github to study Mojolicious framework: However I'm confused by below piece of code ladder sub .... What does it mean in Perl? It looks like not a regular Perl grammar. Btw, I'm with Strawberry Perl 5. # The…
Hao
  • 418
  • 3
  • 8
7
votes
1 answer

How can I use Mojolicious rendering in a standalone Perl script?

I want to render .html.ep templates using Mojolicious rendering engine in a standalone script which sends e-mails and is run from cron: #!/usr/bin/perl use feature ':5.10'; use Mojo::Base -strict; use Mojolicious::Renderer; use Data::Dumper; my…
Victor
  • 127
  • 6
7
votes
2 answers

How to debug server side script for file uploading from client (curl at this example)?

I am trying to write a Perl Mojolicious request from CLI. I want to pass a file as a parameter to this request. Below are the things I have tried so far, but no avail. Below Example is what working fine with me. curl (working): curl -X POST…
7
votes
1 answer

What is the purpose of a route name in mojolicious?

I have been learning how to program apps using the Mojolicious framework and I am stumped as to why you use route names. For example a route could say $r->route('/cities/new') ->via('get') ->to(controller => 'cities', action =>…
user1876508
  • 12,864
  • 21
  • 68
  • 105
7
votes
3 answers

Mojolicious lite how to redirect for not found and server error pages to user defined error page

How to redirect user defined error page for not found and server error pages to user define page Mojolicious lite
joe
  • 34,529
  • 29
  • 100
  • 137
7
votes
1 answer

Mojolicious::Lite with Template Toolkit

I'm trying to get Template Toolkit to work as the default renderer in Mojolicious::Lite. What I have: use strict; use warnings; use Mojolicious::Lite; use Mojolicious::Plugin::TtRenderer; plugin tt_renderer => { template_options => { INCLUDE_PATH…
friedo
  • 65,762
  • 16
  • 114
  • 184
7
votes
1 answer

How do I turn the return value of a Perl sub into an arrayref?

I try the code like this: my @rows = getRows($sth); $self->stash(rows => \@rows); The getRows is a sub function name, and the code works in template. The $rows is a Array. I write code like this: $self->stash(rows => \getRows($sth)); The $rows is…
Tony
  • 321
  • 1
  • 2
  • 6
6
votes
1 answer

Globals and Threads in Mojolicious for handling different paths

In my Mojolicious perl code I handle a jobs created and watched from a remote client. I keep the jobs in a array of hashes, which is a global variable. It is then used in handlers of PUT '/job/create' and GET '/job/status'. When adding a new job…
Juan Macek
  • 270
  • 1
  • 3
  • 10
6
votes
1 answer

Mojolicious - how to intercept the incoming request before controller method handles and renders

In Mojolicious app, I need to figure out which controller method will be handling the incoming request so that I can log details of the remote client and add some logic. I want to do it at only one place and not in every controller methods. I have…
Sachin Dangol
  • 504
  • 5
  • 13
6
votes
1 answer

How to PUT a file using Mojo::Useragent?

I am trying to use the PUT method to upload a file using Mojo::UserAgent, the file may be large, instead of passing the file contents as scalar, is there any other way? This is what I have tried: use strict; use warnings; use Mojo::UserAgent; use…
Pradeep
  • 3,093
  • 17
  • 21
1 2
3
44 45