How to automatically reload a web page when having a certin variable's value?

hoho_dz

New Member
In the following python/html script,I want to refresh the web page automatically when the value of the variable "condition" equal to "1". So that the page show me the new text contains of the variable "myText" automatically. The variable "myText" can have any text, and the following script is just an example.Thanks in advance\[code\]#!/usr/bin/pythonimport cherrypyimport os.pathimport structfrom auth import AuthController, require, member_of, name_isimport subprocessimport commandsclass Server(object): led_logout=0 led_restart=0 condition=0 _cp_config = { 'tools.sessions.on': True, 'tools.auth.on': True } auth = AuthController() @cherrypy.expose @require() def index(self,logout=''): html = """ <html> <head> </head> <body> <p>{htmlText} <p> <a href="http://stackoverflow.com/questions/14425593/?logout=1" onclick="return confirm('Are you sure you want to logout?');"><img src="http://stackoverflow.com/questions/14425593/images/Logout.png"></a> </ul> </body> </html> """ myText = '' myText = "Hello" if logout: self.led_logout = int(logout) if self.led_logout: print "Logout !!!!!" AuthController().logout('/?logout=0') return html.format(htmlText=myText) index.exposed = True#configurationconf = { 'global' : { 'server.socket_host': '0.0.0.0', #0.0.0.0 or specific IP 'server.socket_port': 8085 #server port }, '/images': { #images served as static files 'tools.staticdir.on': True, 'tools.staticdir.dir': os.path.abspath('/home/ubuntu/webserver/images') } }cherrypy.quickstart(Server(), config=conf)\[/code\]
 
Back
Top