paulb@38 | 1 | #!/usr/bin/env python |
paulb@38 | 2 | |
paulb@38 | 3 | "A simple application for test purposes." |
paulb@38 | 4 | |
paulb@38 | 5 | import WebStack.Generic |
paulb@38 | 6 | |
paulb@38 | 7 | class SimpleResource: |
paulb@38 | 8 | |
paulb@38 | 9 | "A simple resource." |
paulb@38 | 10 | |
paulb@38 | 11 | def respond(self, trans): |
paulb@38 | 12 | trans.set_content_type(WebStack.Generic.ContentType("text/html")) |
paulb@38 | 13 | |
paulb@38 | 14 | # Get some information. |
paulb@38 | 15 | |
paulb@38 | 16 | out = trans.get_response_stream() |
paulb@38 | 17 | out.write(""" |
paulb@38 | 18 | <html> |
paulb@38 | 19 | <body> |
paulb@38 | 20 | <h1>Test</h1> |
paulb@38 | 21 | <ul> |
paulb@38 | 22 | <li>Path: %s</li> |
paulb@38 | 23 | <li>Path info: %s</li> |
paulb@38 | 24 | <li>Request method: %s</li> |
paulb@38 | 25 | <li>Content type: %s</li> |
paulb@38 | 26 | <li>Charset: %s</li> |
paulb@38 | 27 | </ul> |
paulb@38 | 28 | </body> |
paulb@38 | 29 | </html> |
paulb@38 | 30 | """ % ( |
paulb@38 | 31 | trans.get_path(), |
paulb@38 | 32 | trans.get_path_info(), |
paulb@38 | 33 | trans.get_request_method(), |
paulb@38 | 34 | trans.get_content_type().content_type, |
paulb@38 | 35 | trans.get_content_type().charset, |
paulb@38 | 36 | )) |
paulb@38 | 37 | |
paulb@38 | 38 | # vim: tabstop=4 expandtab shiftwidth=4 |