From 8505ad4beb81452256683ae3b3b138fe0a938f82 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 10 Feb 2024 18:21:16 +0100 Subject: [PATCH] Fix simple example from the documentation (#105) --- docs/source/quickstart.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/source/quickstart.rst b/docs/source/quickstart.rst index 8439954..b68b06f 100644 --- a/docs/source/quickstart.rst +++ b/docs/source/quickstart.rst @@ -21,10 +21,10 @@ in a simple WSGI application:: # The following two callbacks just append the name to the return value. def on_field(field): - ret.append("Parsed field named: %s" % (field.field_name,)) + ret.append(b"Parsed field named: %s" % (field.field_name,)) def on_file(file): - ret.append("Parsed file named: %s" % (file.field_name,)) + ret.append(b"Parsed file named: %s" % (file.field_name,)) # Create headers object. We need to convert from WSGI to the actual # name of the header, since this library does not assume that you are @@ -40,10 +40,12 @@ in a simple WSGI application:: # Return something. start_response('200 OK', [('Content-type', 'text/plain')]) - ret.append('\n') + ret.append(b'\n') return ret - + from wsgiref.simple_server import make_server + from wsgiref.validate import validator + httpd = make_server('', 8123, simple_app) print("Serving on port 8123...") httpd.serve_forever()