#!/usr/bin/env python
# requires formtest.html in templates/
import web, form, template, config
urls = (
'/', 'index',
)
render = template.render('templates/')
myform = form.Form(
form.Textbox("boe"),
form.Textbox("bax",
form.notnull,
form.Validator('Must be more than 5', lambda x:int(x)>5)),
form.Textarea('moe'),
form.Checkbox('curly'),
form.Dropdown('french', ['mustard', 'fries', 'wine']))
class index:
def GET(self):
form = myform()
print render.formtest(form)
def POST(self):
form = myform()
if not form.validates():
print render.formtest(form)
else:
print "when libraries compete, you win!"
if __name__ == "__main__":
web.run(urls, globals(), *config.middleware)