Mercurial > genshi > mirror
view examples/webpy/hello.py @ 270:d9d3b844442b trunk
The [WebPy web.py] example was generating extraneous line breaks.
author | cmlenz |
---|---|
date | Wed, 27 Sep 2006 09:20:45 +0000 |
parents | 8165d6e3b703 |
children | 370fa02591a8 |
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) for output in stream.serialize('html'): print output.encode('utf-8'), if __name__ == '__main__': web.internalerror = web.debugerror web.run(urls)