Refresh a Route periodically
Dear Perl Dancer Experts, I am new to perl dancer. Thank you for the dancer framework. I could ramp-up quickly w.r.t using dancer framework to develop simple web-pages. I am trying to develop a webpage where I would like to have contents of a webpage refreshed (say after every x seconds). I briefly went through the mailing lists and other sites and I figured out that AnyEvent from Twiggy might be one solution to do it. I wanted to solve the problem by redirecting a route to itself after every x seconds. something like : get '/' => sub { $w = AnyEvent->timer(after => 1, interval => 15, cb => sub { # do some database retrievals redirect "/"; }); template 'index'; }; Could you please suggest if this will work , or if there is any other better and easier way to do it. Also : When I try installing Twiggy by using cpanm Twiggy, the installation gets stuck at the point "Building and testing Test-SharedFork-0.21 ...". I am using a windows 64 bit machine with strawberry perl, with version - 5.10.1. could you please help with a solution for this? Thank you in advance Best Regards Ajay MK
On 13-07-02 05:56 PM, Anand Meher wrote:
I am trying to develop a webpage where I would like to have contents of a webpage refreshed (say after every x seconds).
Dancer::Plugin::Cache::CHI, perhaps ? get '/' => sub { # only recomputed every 5 minutes cache_page template( 'index' ), 300; }; Joy, `/anick
On Jul 2, 2013, at 7:14 PM, Yanick Champoux <yanick@babyl.dyndns.org> wrote:
On 13-07-02 05:56 PM, Anand Meher wrote:
I am trying to develop a webpage where I would like to have contents of a webpage refreshed (say after every x seconds).
Dancer::Plugin::Cache::CHI, perhaps ?
get '/' => sub { # only recomputed every 5 minutes cache_page template( 'index' ), 300; };
Client-side pull perhaps? In other words, nothing to do with Dancer... Just use JS to poll every five mins for new results. -- Puneet Kishor
On Tue, Jul 2, 2013 at 4:56 PM, Anand Meher <kvmsanand@gmail.com> wrote:
Dear Perl Dancer Experts, I am new to perl dancer. Thank you for the dancer framework. I could ramp-up quickly w.r.t using dancer framework to develop simple web-pages.
I am trying to develop a webpage where I would like to have contents of a webpage refreshed (say after every x seconds).
I briefly went through the mailing lists and other sites and I figured out that AnyEvent from Twiggy might be one solution to do it.
I wanted to solve the problem by redirecting a route to itself after every x seconds.
something like :
get '/' => sub {
$w = AnyEvent->timer(after => 1, interval => 15, cb => sub {
# do some database retrievals
redirect "/";
});
template 'index';
};
Could you please suggest if this will work , or if there is any other better and easier way to do it.
Also : When I try installing Twiggy by using cpanm Twiggy, the installation gets stuck at the point "Building and testing Test-SharedFork-0.21 ...". I am using a windows 64 bit machine with strawberry perl, with version - 5.10.1.
I have virtually no experience with Perl on Windows. So it's probably safest to ignore me. But it's possible that the problem is only with the test module having some kind of problem on Windows--the module you're trying to install might actually work ok if you skip the tests or force the install. (cpanm --help). mike
could you please help with a solution for this?
Thank you in advance
Best Regards Ajay MK
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
Hi, On Tue, Jul 2, 2013 at 10:56 PM, Anand Meher <kvmsanand@gmail.com> wrote:
Dear Perl Dancer Experts, I am new to perl dancer. Thank you for the dancer framework. I could ramp-up quickly w.r.t using dancer framework to develop simple web-pages.
I am trying to develop a webpage where I would like to have contents of a webpage refreshed (say after every x seconds).
Maybe I'm misunderstanding but why do you need server side support for this? The basic way of doing this is to add a <meta> tag to your HTML like this: <meta http-equiv="refresh" content="60;url=URL_OF_YOUR_PAGE_GOES_HERE" /> The 60 above is the number of seconds until refresh. Replace it with the proper place. An alternative solution is a bit of Javascript that sets a timer and forces the refresh when it expires. You can even just refresh the parts of the page you need, with an AJAX request. Maybe I misunderstood what you want to do, but I see no reason to do this server side on your explanation. Bye. -- Pedro Melo @pedromelo http://www.simplicidade.org/ xmpp:melo@simplicidade.org mailto:melo@simplicidade.org
participants (5)
-
Anand Meher -
Mike South -
Pedro Melo -
Puneet Kishor -
Yanick Champoux