annotate examples/cherrypy/index.py @ 351:50f4e199e3aa

The `py:content`, `py:replace`, and `py:strip=""` directives are now expanded when the template is loaded (as opposed to when it's rendered).
author cmlenz
date Fri, 10 Nov 2006 23:32:24 +0000
parents aa16cebbcfe4
children 3879c9ad3472
rev   line source
266
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
1 import os
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
2 import sys
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
3
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
4 import cherrypy
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
5 from genshi.template import TemplateLoader
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
6
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
7 loader = TemplateLoader([os.path.dirname(os.path.abspath(__file__))])
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
8
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
9
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
10 class Example(object):
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
11
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
12 @cherrypy.expose
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
13 def index(self):
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
14 tmpl = loader.load('index.html')
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
15 return tmpl.generate(name='world').render('xhtml')
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
16
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
17
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
18 cherrypy.root = Example()
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
19
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
20 if __name__ == '__main__':
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
21 cherrypy.config.update(file='config.txt')
aa16cebbcfe4 Added an example CherryPy application.
cmlenz
parents:
diff changeset
22 cherrypy.server.start()
Copyright (C) 2012-2017 Edgewall Software