paulb@303 | 1 | #!/usr/bin/env python |
paulb@303 | 2 | |
paulb@303 | 3 | from WebStack.Adapters import WSGI |
paulb@303 | 4 | from Calendar import DirectoryResource |
paulb@303 | 5 | from wsgiutils import wsgiServer, wsgiAdaptor |
paulb@303 | 6 | |
paulb@303 | 7 | # Magic dictionary for WSGIServer. |
paulb@303 | 8 | |
paulb@303 | 9 | class MagicDict: |
paulb@303 | 10 | def __init__(self, handler): |
paulb@303 | 11 | self.handler = handler |
paulb@303 | 12 | def has_key(self, name): |
paulb@303 | 13 | return 1 |
paulb@303 | 14 | def __getitem__(self, name): |
paulb@303 | 15 | return self.handler |
paulb@303 | 16 | |
paulb@303 | 17 | # Special magic incantation. |
paulb@303 | 18 | |
paulb@303 | 19 | handler = WSGI.WSGIAdapter(DirectoryResource()) |
paulb@303 | 20 | address = ("", 8080) |
paulb@303 | 21 | server = wsgiServer.WSGIServer(address, MagicDict(handler)) |
paulb@303 | 22 | print "Serving..." |
paulb@303 | 23 | server.serve_forever() |
paulb@303 | 24 | |
paulb@303 | 25 | # vim: tabstop=4 expandtab shiftwidth=4 |