Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 59 lines (47 sloc) 1.248 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

Something went wrong with that request. Please try again.