Question

I want a better way to update images on a webpage instead of forcing the webpage to refresh every 60 seconds.

I wrote a little status page that monitors some of our web sites. It uses web.py and displays a list of servers I have inputted into a database.

Each server that is up gets a Green png image displayed next to it.

When a server goes down I update the status in a local mysql database to false.

The next time the page refreshes it gets a red png displayed next to it.

Right now that red png file does not display until I refresh the page.

Is there a way in web.py (python) that I can make just that image dynamic without having to refresh the whole page? Or do I have to use something else to make it work?

Était-ce utile?

La solution

Well, the generic answer is that you use AJAX and put a script on each server that will return "up" or something every time your page checks.

Here's a tutorial on how to do AJAX with web.py specifically: http://kooneiform.wordpress.com/2010/02/28/python-and-ajax-for-beginners-with-webpy-and-jquery/

Autres conseils

I have no knowledge related to web.py.

But in my point of view what you gonna need is to break your code in two parts (a monitor service and a monitor display) and use javascript to asynchronously update the data.

Your monitor service will provide a url that receives the monitored site ID and returns up or down. As you are using web.py, it will probably be 100% python.

Your monitor display will use javascript to ever X seconds checks that url and show the correct icon. It can be python based, or not. But it will need javascript.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top