public
Created

canvas example

  • Download Gist
gistfile1.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
from canvas import HtmlCanvas
from bottle import run,route
 
def render(page):
canvas = HtmlCanvas()
return canvas.render(page)
 
 
class BasePage(object):
 
def render_on(self, canvas):
with canvas.head():
canvas.title(self.title)
with canvas.body():
with canvas.div(id='content'):
self.render_content_on(canvas)
 
def render_content_on(self, canvas):
pass
 
 
class HomePage(BasePage):
title = 'Home'
 
def render_content_on(self, canvas):
canvas.h1('Welcome')
 
 
@route('/')
def index():
return render(HomePage())

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.