Wednesday, 4 July 2007

Ajax in CherryPy - A simple Example



import cherrypy

_header = """

Define your Validate function in Ajax

"""

class Start(object):
@cherrypy.expose
def index(self):
page=[_header]
page.append("""your Code here to call the function...""")
return page

@cherrypy.expose
def ajax(self,w):
return str(w)


if __name__ == '__main__':
global_conf = {
'global': { 'engine.autoreload.on': True,
'server.socket_host': 'localhost',
'server.socket_port': 8080,
}}
cherrypy.config.update(global_conf)
note_app = Start()
cherrypy.tree.mount(note_app, '/')


cherrypy.server.quickstart()
cherrypy.engine.start()

No comments: