# HG changeset patch # User paulb # Date 1079022091 0 # Node ID 51886dcd2aa65bd673390a477d766031a5fc54ad # Parent 72dab6ed1872cee19061835ca7f86167c588956b [project @ 2004-03-11 16:21:29 by paulb] Added missing file. diff -r 72dab6ed1872 -r 51886dcd2aa6 examples/BaseHTTPRequestHandler/FormApp.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/BaseHTTPRequestHandler/FormApp.py Thu Mar 11 16:21:31 2004 +0000 @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +from WebStack.Adapters import BaseHTTPRequestHandler +from Form import FormResource +import BaseHTTPServer + +# Special magic incantation. + +handler = BaseHTTPRequestHandler.HandlerFactory(FormResource()) +address = ("", 8080) +server = BaseHTTPServer.HTTPServer(address, handler) +server.serve_forever() + +# vim: tabstop=4 expandtab shiftwidth=4 diff -r 72dab6ed1872 -r 51886dcd2aa6 examples/Common/Form/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/Common/Form/__init__.py Thu Mar 11 16:21:31 2004 +0000 @@ -0,0 +1,62 @@ +#!/usr/bin/env python + +"A form submission test." + +import WebStack.Generic + +class FormResource: + + """ + A resource which handles incoming form submissions. + """ + + def respond(self, trans): + + """ + Examine the incoming request, decoding the form information. + """ + + # NOTE: Some frameworks do not pass in the content type. + + content_type = trans.get_content_type() + input = trans.get_request_stream() + received_data = input.read() + + # NOTE: Send the appropriate kind of response. + + trans.set_content_type(WebStack.Generic.ContentType("text/html")) + out = trans.get_response_stream() + out.write(""" + + + Form Test + + +

Form Test

+

Normal

+
+
+
+
+
+ +
+

Multipart

+
+
+
+
+
+ +
+

Content Type

+

%s

+

Received Data

+

Start

+
%s
+

Stop

+ + +""" % (content_type.content_type, received_data.replace("<", "<").replace(">", ">").replace("&", "&"))) + +# vim: tabstop=4 expandtab shiftwidth=4