#!/usr/bin/env python """Forms A simple example showing how to deal with data forms. """ from circuits.web import Controller, Server FORM = """ Basic Form Handling

Basic Form Handling

Example of using circuits and its Web Components to build a simple web application that handles some basic form data.

First Name:
Last Name:
""" class Root(Controller): def index(self): """Request Handler Our index request handler which simply returns a response containing the contents of our form to display. """ return FORM def save(self, firstName, lastName): """Save Request Handler Our /save request handler (which our form above points to). This handler accepts the same arguments as the fields in the form either as positional arguments or keyword arguments. We will use the date to pretend we've saved the data and tell the user what was saved. """ return "Data Saved. firstName={0:s} lastName={1:s}".format( firstName, lastName ) app = Server(("0.0.0.0", 8000)) Root().register(app) app.run()