1.1 --- a/examples/BaseHTTPRequestHandler/DemoApp.py Wed Sep 28 23:08:07 2005 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,100 +0,0 @@
1.4 -#!/usr/bin/env python
1.5 -
1.6 -"""
1.7 -A demonstration of WebStack. 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 -from WebStack.Resources.LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator
1.16 -from WebStack.Resources.Login import LoginResource, LoginAuthenticator
1.17 -
1.18 -# Here are all the test resources.
1.19 -
1.20 -from Cookies import CookiesResource
1.21 -from Form import FormResource
1.22 -from Sessions import SessionsResource
1.23 -from Simple import SimpleResource
1.24 -from Unicode import UnicodeResource
1.25 -from VerySimple import VerySimpleResource
1.26 -from Calendar import CalendarResource
1.27 -
1.28 -# A very simple index page.
1.29 -
1.30 -from WebStack.Generic import ContentType
1.31 -
1.32 -class DemoResource:
1.33 - def respond(self, trans):
1.34 - trans.set_content_type(ContentType("text/html"))
1.35 - trans.get_response_stream().write("""
1.36 -<html>
1.37 - <head>
1.38 - <title>WebStack Examples</title>
1.39 - </head>
1.40 - <body>
1.41 - <h1>WebStack Examples</h1>
1.42 - <p>Here are some of the examples supplied with WebStack:</p>
1.43 - <ul>
1.44 - <li><a href="cookies">Cookie information</a></li>
1.45 - <li><a href="form">Form tests</a></li>
1.46 - <li><a href="sessions">Session information</a></li>
1.47 - <li><a href="simple">Simple test</a></li>
1.48 - <li><a href="simplewithlogin">Simple with login test</a></li>
1.49 - <li><a href="unicode">Unicode test</a></li>
1.50 - <li><a href="verysimple">Very simple test</a></li>
1.51 - <li><a href="webdav://localhost:8080/calendar/">Calendar store example</a> - <strong>requires a WebDAV-capable browser</strong><br />
1.52 - Copy calendar files into the directory, view them, delete them, and so on.</li>
1.53 - </ul>
1.54 - <p>You can run all of the examples independently - see the documentation in
1.55 - the <code>docs</code> directory, especially the subdirectories for each
1.56 - of the server environments or frameworks, for details of how this is
1.57 - done.</p>
1.58 - </body>
1.59 -</html>""")
1.60 - trans.set_response_code(200)
1.61 -
1.62 -# Define the resource mapping.
1.63 -
1.64 -resource = MapResource({
1.65 - "cookies" : CookiesResource(),
1.66 - "form" : FormResource(),
1.67 - "sessions" : SessionsResource(),
1.68 - "simple" : SimpleResource(),
1.69 - "simplewithlogin" :
1.70 - LoginRedirectResource(
1.71 - login_url="http://localhost:8080/login",
1.72 - app_url="http://localhost:8080",
1.73 - resource=SimpleResource(),
1.74 - authenticator=LoginRedirectAuthenticator(secret_key="horses"),
1.75 - anonymous_parameter_name="anonymous",
1.76 - logout_parameter_name="logout"
1.77 - ),
1.78 - "login" :
1.79 - LoginResource(
1.80 - LoginAuthenticator(
1.81 - secret_key="horses",
1.82 - credentials=(
1.83 - ("badger", "abc"),
1.84 - ("vole", "xyz"),
1.85 - )
1.86 - )
1.87 - ),
1.88 - "unicode" : UnicodeResource(),
1.89 - "verysimple" : VerySimpleResource(),
1.90 - "calendar" : CalendarResource(),
1.91 - "" : DemoResource()
1.92 - })
1.93 -
1.94 -# Uncomment the line below to test arbitrary depth URLs/paths.
1.95 -
1.96 -#resource.mapping[None] = resource
1.97 -
1.98 -# Special magic incantation.
1.99 -
1.100 -print "Serving..."
1.101 -deploy(resource, handle_errors=0)
1.102 -
1.103 -# vim: tabstop=4 expandtab shiftwidth=4