Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
59 lines (47 sloc) 1.22 KB
layout title
default
Templating with Genshi

Templating with Genshi

code.py

Put your "code.py" in root directory.

# -*- coding: utf-8 -*-
 
import web
from web.contrib import template
 
render = template.render_genshi(['./templates/'])
 
urls = (
    '/', 'index'
)
 
class index:
    def GET(self):
        name = 'John Doe'
        return render.index(name=name)
 
app = web.application(urls, globals())
if __name__ == "__main__":
    app.run()

index.html

Put your "index.html" in "template" directory.

<?xml version="1.0" encoding="utf-8"?>
<html xmlns:py="http://genshi.edgewall.org/">
<body>
<p>Hello, $name.</p>
</body>
</html>

refer