1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/examples/BaseHTTPRequestHandler/DemoApp.py Sat Jul 16 20:35:26 2005 +0000
1.3 @@ -0,0 +1,59 @@
1.4 +#!/usr/bin/env python
1.5 +
1.6 +"""
1.7 +A demonstration of XSLTools. This is a quick and dirty combination of an
1.8 +adapter, employing lots of resources, and the index page resource.
1.9 +"""
1.10 +
1.11 +# Import the things which make the adapter code deploy the application.
1.12 +
1.13 +from WebStack.Adapters.BaseHTTPRequestHandler import deploy
1.14 +from WebStack.Resources.ResourceMap import MapResource
1.15 +
1.16 +# Here are all the example applications.
1.17 +
1.18 +import Configurator
1.19 +import Questionnaire
1.20 +import PEP241
1.21 +
1.22 +# A very simple index page.
1.23 +
1.24 +from WebStack.Generic import ContentType
1.25 +
1.26 +class DemoResource:
1.27 + def respond(self, trans):
1.28 + trans.set_content_type(ContentType("text/html"))
1.29 + trans.get_response_stream().write("""
1.30 +<html>
1.31 + <head>
1.32 + <title>XSLTools Examples</title>
1.33 + </head>
1.34 + <body>
1.35 + <h1>XSLTools Examples</h1>
1.36 + <p>Here are some of the examples supplied with XSLTools:</p>
1.37 + <ul>
1.38 + <li><a href="configurator">A Webshop-style system configurator</a></li>
1.39 + <li><a href="questionnaire">A questionnaire generator</a></li>
1.40 + <li><a href="pep241">A Python package repository user interface</a></li>
1.41 + </ul>
1.42 + <p>You can run all of the examples independently, too. See the
1.43 + <code>examples</code> directory for the code.</p>
1.44 + </body>
1.45 +</html>""")
1.46 + trans.set_response_code(200)
1.47 +
1.48 +# Define the resource mapping.
1.49 +
1.50 +resource = MapResource({
1.51 + "configurator" : Configurator.get_site(),
1.52 + "questionnaire" : Questionnaire.get_site(),
1.53 + "pep241" : PEP241.get_site(),
1.54 + "" : DemoResource(),
1.55 + })
1.56 +
1.57 +# Special magic incantation.
1.58 +
1.59 +print "Serving..."
1.60 +deploy(resource, handle_errors=0)
1.61 +
1.62 +# vim: tabstop=4 expandtab shiftwidth=4