paulb@97 | 1 | #!/usr/bin/env python |
paulb@97 | 2 | |
paulb@97 | 3 | # NOTE: Path manipulation requires manual customisation. |
paulb@97 | 4 | |
paulb@97 | 5 | import sys |
paulb@97 | 6 | sys.path.append("/home/paulb/Software/Python/WebStack") |
paulb@97 | 7 | sys.path.append("/home/paulb/Software/Python/XSLTools") |
paulb@97 | 8 | sys.path.append("/home/paulb/Software/Python/XSLTools/examples/Common") |
paulb@97 | 9 | sys.path.append("/home/paulb/Software/Python/libxml2dom") |
paulb@97 | 10 | |
paulb@97 | 11 | from WebStack.Adapters import ModPython |
paulb@97 | 12 | from WebStack.Resources.ResourceMap import MapResource |
paulb@97 | 13 | from WebStack.Resources.Static import DirectoryResource |
paulb@97 | 14 | import Configurator |
paulb@97 | 15 | import os |
paulb@97 | 16 | |
paulb@97 | 17 | # Get the directory of the application. |
paulb@97 | 18 | |
paulb@97 | 19 | configurator_resource = Configurator.ConfiguratorResource() |
paulb@97 | 20 | directory = configurator_resource.resource_dir |
paulb@97 | 21 | |
paulb@97 | 22 | # Make a simple Web site. |
paulb@97 | 23 | |
paulb@97 | 24 | resource = MapResource({ |
paulb@97 | 25 | # Static resources: |
paulb@97 | 26 | "styles" : DirectoryResource(os.path.join(directory, "styles"), {"css" : "text/css"}), |
paulb@97 | 27 | "scripts" : DirectoryResource(os.path.join(directory, "scripts"), {"js" : "text/javascript"}), |
paulb@97 | 28 | # Main page: |
paulb@97 | 29 | "" : configurator_resource, |
paulb@97 | 30 | # Fragments: |
paulb@97 | 31 | "cpu" : configurator_resource, |
paulb@97 | 32 | "memory" : configurator_resource, |
paulb@97 | 33 | "hard-disks" : configurator_resource |
paulb@97 | 34 | }) |
paulb@97 | 35 | |
paulb@97 | 36 | # NOTE: Not sure if the resource should be maintained in a resource pool. |
paulb@97 | 37 | |
paulb@97 | 38 | def handler(req): |
paulb@97 | 39 | global resource |
paulb@97 | 40 | return ModPython.respond(req, resource, handle_errors=0) |
paulb@97 | 41 | |
paulb@97 | 42 | # vim: tabstop=4 expandtab shiftwidth=4 |