mojolicious

Mojolicious Deploying database schema

余生长醉 提交于 2019-12-11 12:22:46
问题 I am currently working through this tutorial on building a Mojolicious web app for a project. In the tutorial he talks about using this in a script to create a database schema. my $schema = Moblo::Schema->connect('dbi:SQLite:moblo.db'); $schema->deploy(); and I have tried running perl -e '...' , putting it in different files and everything else I can think of, but with no success. Here is my code on GitHub. I am pretty lost on how to get this thing to create the schema so any help would be

How to I get the right json-datatype for the autocomplete function?

こ雲淡風輕ζ 提交于 2019-12-11 10:47:47
问题 When I try this, it works as expected: after two characters its shows the matching entries. <!DOCTYPE HTML> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <script src="development-bundle/jquery-1.6.2.js"></script> <script src="development-bundle/ui/jquery.ui.core.js"></script> <script src="development-bundle/ui/jquery.ui.widget.js"></script> <script src="development-bundle/ui/jquery.ui.position.js"></script> <script src="development-bundle/ui/jquery.ui

How do I set the base URL for my proxied app?

*爱你&永不变心* 提交于 2019-12-11 03:41:47
问题 I need to place a Mojolicious app behind an Apache reverse proxy. I've been unable to get Mojolicious to generate working URLs when behind the proxy. I'm using Mojolicious 6.14 with Perl 5.18.1. Here's my Apache reverse proxy configuration which I set based on https://github.com/kraih/mojo/wiki/Apache-deployment (in the path section). <Proxy *> Order deny,allow Allow from all </Proxy> ProxyRequests Off ProxyPreserveHost On ProxyPass /app1 http://localhost:3000/ keepalive=On ProxyPassReverse

Mojolicious is not capturing URL (only base url)

梦想的初衷 提交于 2019-12-10 18:37:52
问题 I created a simple API using mojolicious , but I've just migrated from Apache to Nginx and cannot figure out how to handle url correctly Here is my Server Block configuration file server { listen 80; listen [::]:80; root /var/www/example.com/public_html; index index.pl index.html index.htm index.nginx-debian.html; server_name example.com www.example.com; location / { gzip off; include /etc/nginx/fastcgi_params; fastcgi_pass 127.0.0.1:8090; fastcgi_param SCRIPT_FILENAME /var/www/example/public

How should I process HTML META tags with Mojo::UserAgent?

隐身守侯 提交于 2019-12-10 13:49:33
问题 I have to play with some misconfigured web servers, so I started processing the HTML meta tags to feed information back into the web user-agent object. I tried a variety of ways of doing this in Mojolicious and settled on a looking for a "finish" event on the response. My goal was to make this mostly invisible to the rest of the code so the process wasn't even aware this was happening. Still, this just doesn't sit right with me for a reason I can't quite put my finger on. Aside from the

Why websocket connections breaks

好久不见. 提交于 2019-12-10 13:27:56
问题 After I run client against websocket echo server, it disconnects after about half a minute with WebSocket closed with status 1006 message. Please suggest how to avoid such behavior (browser clients does not seem to be affected) use 5.20.0; use Mojo::UserAgent; use Mojo::IOLoop; sub ws_connect { state $ua; say "Connecting.."; $ua = Mojo::UserAgent->new; $ua->websocket('ws://127.0.0.1:3000/echo' => \&onConnect); } sub onConnect { my ($ua, $tx) = @_; if (!$tx->is_websocket) { say 'WebSocket

How to add and remove routes dynamically in Mojolicious?

喜夏-厌秋 提交于 2019-12-10 10:56:30
问题 I am trying to put together a maintenance page in my Mojolicious app which all of my users will be shown whenever a file or DB entry is present on the server. I know I can check for this file or entry on startup and if its there add in my 'catch all' route. However I'm not sure how to do this dynamically? I don't want to have to restart the backend whenever I want to go into maintenance. Is there a way to add and remove routes from a hook? for example use the before dispatch hook to monitor

Globals and Threads in Mojolicious for handling different paths

只愿长相守 提交于 2019-12-10 04:29:36
问题 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 with the PUT '/job/create' the array gets extended in the subroutine (it contains 4 elements in the code below), but when requesting the jobs' status via GET '/job/status' the list of jobs, the array does not contain the added elements (it counts 2

mojolicious referencing a stash variable not always defined

我只是一个虾纸丫 提交于 2019-12-10 02:36:58
问题 I am still learning mojolicious and MVC frameworks in general so this just might be a problem where I am thinking about this wrong so if I am please suggest a better way to do the following. I have a route /route/:param where param is sometimes defined and sometimes not. I am trying to use "param" in the template for that route but I get an error saying "param" requires explicit package name. I know this is due to :param not matching in the route because when I do call /route/value everything

Mojolicious: should I use one websocket or several?

你。 提交于 2019-12-09 21:29:18
问题 I'm teaching myself about Mojolicious and websockets. So far I've got a web page that displays rows from a database, and has buttons to add, delete, and update rows, and to select columns for sorting. At the moment, it uses 'one-shot' websockets in the javascript 'onclick' handlers for each button, and that works. Would it be more in-keeping with the intention of websockets, for the sockets to be kept alive and used for multiple clicks? I think the answer should be 'yes', because otherwise it