summaryrefslogtreecommitdiffstats
path: root/Doc/howto/webservers.rst
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-12-05 18:04:41 (GMT)
committerGeorg Brandl <georg@python.org>2008-12-05 18:04:41 (GMT)
commit6d204bf9b6ab4166c2ebcde5c17f615105748d6e (patch)
tree258dd24ce6c9e1cab198dfad2e96235ddfa14c9e /Doc/howto/webservers.rst
parent50b2b6eeacb49d46d194cfa8028788fe2a670d9e (diff)
downloadcpython-6d204bf9b6ab4166c2ebcde5c17f615105748d6e.zip
cpython-6d204bf9b6ab4166c2ebcde5c17f615105748d6e.tar.gz
cpython-6d204bf9b6ab4166c2ebcde5c17f615105748d6e.tar.bz2
#4550: fix 2.x syntax in webservers howto.
Diffstat (limited to 'Doc/howto/webservers.rst')
-rw-r--r--Doc/howto/webservers.rst15
1 files changed, 8 insertions, 7 deletions
diff --git a/Doc/howto/webservers.rst b/Doc/howto/webservers.rst
index 97c2267..401f94e 100644
--- a/Doc/howto/webservers.rst
+++ b/Doc/howto/webservers.rst
@@ -101,10 +101,10 @@ simple CGI program::
# 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
@@ -278,8 +278,8 @@ following WSGI-application::
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
- from cgi import escape
import sys, os
+ from cgi import escape
from flup.server.fcgi import WSGIServer
def app(environ, start_response):
@@ -288,7 +288,8 @@ following WSGI-application::
yield '<h1>FastCGI Environment</h1>'
yield '<table>'
for k, v in sorted(environ.items()):
- yield '<tr><th>%s</th><td>%s</td></tr>' % (escape(k), escape(v))
+ yield '<tr><th>{0}</th><td>{1}</td></tr>'.format(
+ escape(k), escape(v))
yield '</table>'
WSGIServer(app).run()
@@ -476,8 +477,8 @@ placeholders.
Python already includes such simple templates::
# a simple template
- template = "<html><body><h1>Hello %s!</h1></body></html>"
- print template % "Reader"
+ template = "<html><body><h1>Hello {who}!</h1></body></html>"
+ print(template.format(who="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