--- webservers.txt 2008-12-04 07:15:58.000000000 -0600 +++ webservers-3k.txt 2008-12-05 10:48:30.000000000 -0600 @@ -95,16 +95,16 @@ To test whether your web server works with CGI, you can use this short and simple CGI program:: - #!/usr/bin/env python + #!/usr/bin/env python3.0 # -*- coding: UTF-8 -*- # enable debugging import cgitb; cgitb.enable() - print "Content-Type: text/plain;charset=utf-8" - print + print("Content-Type: text/plain;charset=utf-8") + print() - print "Hello World!" + print("Hello World!") You need to write this code into a file with a ``.py`` or ``.cgi`` extension, this depends on your web server configuration. Depending on your web server @@ -275,7 +275,7 @@ Once you have installed and configured the module, you can test it with the following WSGI-application:: - #!/usr/bin/env python + #!/usr/bin/env python3.0 # -*- coding: UTF-8 -*- from cgi import escape @@ -285,11 +285,12 @@ def app(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) - yield '

FastCGI Environment

' - yield '' + yield('

FastCGI Environment

') + yield('
') for k, v in sorted(environ.items()): - yield '' % (escape(k), escape(v)) - yield '
%s%s
' + yield('{0}{1}'.format( + escape(k), escape(v)) + yield('') WSGIServer(app).run() @@ -476,8 +477,8 @@ Python already includes such simple templates:: # a simple template - template = "

Hello %s!

" - print template % "Reader" + template = "

Hello {0}!

" + print(template.format("Reader")) The Python standard library also includes some more advanced templates usable through :class:`string.Template`, but in HTML templates it is needed to use