2004-02-01 | paulb | file changeset files shortlog | [project @ 2004-02-01 16:38:52 by paulb] Enhanced the output for the simple application. |
paulb@7 | 1 | #!/usr/bin/env python |
paulb@7 | 2 | |
paulb@7 | 3 | "A simple application for test purposes." |
paulb@7 | 4 | |
paulb@7 | 5 | import WebStack.Generic |
paulb@7 | 6 | |
paulb@7 | 7 | class SimpleResource: |
paulb@7 | 8 | |
paulb@7 | 9 | "A simple resource." |
paulb@7 | 10 | |
paulb@7 | 11 | def respond(self, trans): |
paulb@7 | 12 | trans.set_content_type(WebStack.Generic.ContentType("text/html")) |
paulb@12 | 13 | |
paulb@12 | 14 | # Get some information. |
paulb@12 | 15 | |
paulb@12 | 16 | path_info, path = "", "" |
paulb@12 | 17 | |
paulb@12 | 18 | try: |
paulb@12 | 19 | path_info = trans.get_path_info() |
paulb@12 | 20 | path = trans.get_path() |
paulb@12 | 21 | except NotImplementedError: |
paulb@12 | 22 | pass |
paulb@12 | 23 | |
paulb@7 | 24 | out = trans.get_response_stream() |
paulb@12 | 25 | out.write(""" |
paulb@12 | 26 | <html> |
paulb@12 | 27 | <body> |
paulb@12 | 28 | <h1>Test</h1> |
paulb@12 | 29 | <p> |
paulb@12 | 30 | Path: %s |
paulb@12 | 31 | </p> |
paulb@12 | 32 | <p> |
paulb@12 | 33 | Path info: %s |
paulb@12 | 34 | </p> |
paulb@12 | 35 | </body> |
paulb@12 | 36 | </html> |
paulb@12 | 37 | """ % (path, path_info)) |
paulb@7 | 38 | |
paulb@7 | 39 | # vim: tabstop=4 expandtab shiftwidth=4 |