view examples/webpy/hello.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 b5b2a84e4b71
children 42c6cfdd5582
line wrap: on
line source
import os
from genshi.template import TemplateLoader
import web

loader = TemplateLoader([os.path.dirname(os.path.abspath(__file__))],
                        auto_reload=True)
urls = ('/(.*)', 'hello')


class hello(object):

    def GET(self, name):
        i = web.input(times=1)
        if not name:
            name = 'world'
        name = name.decode('utf-8')

        tmpl = loader.load('hello.html')
        stream = tmpl.generate(name=name, times=int(i.times))

        web.header('Content-Type', 'text/html; charset=utf-8', unique=True)
        print stream.render('html')


if __name__ == '__main__':
    web.internalerror = web.debugerror
    web.run(urls)
Copyright (C) 2012-2017 Edgewall Software