WebStack

Annotated examples/BaseHTTPRequestHandler/SimpleWithLoginApp.py

153:e621441ea8b8
2004-05-30 paulb [project @ 2004-05-30 16:41:14 by paulb] Added logout handling.
paulb@147 1
#!/usr/bin/env python
paulb@147 2
paulb@147 3
from WebStack.Adapters import BaseHTTPRequestHandler
paulb@147 4
from Simple import SimpleResource
paulb@147 5
from LoginRedirect import LoginRedirectResource, LoginRedirectAuthenticator
paulb@147 6
import BaseHTTPServer
paulb@147 7
paulb@147 8
# Special magic incantation.
paulb@147 9
paulb@147 10
handler = BaseHTTPRequestHandler.HandlerFactory(
paulb@147 11
    LoginRedirectResource(
paulb@147 12
        login_url="http://localhost:8081",
paulb@147 13
        app_url="http://localhost:8080",
paulb@147 14
        resource=SimpleResource(),
paulb@147 15
        authenticator=LoginRedirectAuthenticator(secret_key="horses"),
paulb@153 16
        anonymous_parameter_name="anonymous",
paulb@153 17
        logout_parameter_name="logout"
paulb@147 18
    )
paulb@147 19
)
paulb@147 20
address = ("", 8080)
paulb@147 21
server = BaseHTTPServer.HTTPServer(address, handler)
paulb@147 22
print "Serving..."
paulb@147 23
server.serve_forever()
paulb@147 24
paulb@147 25
# vim: tabstop=4 expandtab shiftwidth=4