Using HTMLTemplate with CherryPy
HTMLTemplate can be downloaded here
test.html
<html> <head> <title node="con:pagetitle">Test title</title> </head> <body> <p node="con:myquote">Test quote</p> </body> </html>
test.py
import cherrypy from HTMLTemplate import Template class Begin: def renderTemplate(self, node, title, quote): node.pagetitle.content = title node.myquote.content = quote @cherrypy.expose def index(self): html = file("test.html").read() template = Template(self.renderTemplate, html) return template.render('Quote of the Day', 'God does not play dice.') cherrypy.quickstart(Begin())
Older versions
| replace this | with this | |
| 2.2 | cherrypy.quickstart(Begin()) | cherrypy.root = Begin() cherrypy.server.start() |
| 2.0 | import cherrypy | from cherrypy import cpg as cherrypy |

