doc: Fixed typo.
[ashd.git] / python / ashd / wsgiutil.py
CommitLineData
c06db49a
FT
1def htmlquote(text):
2 ret = ""
3 for c in text:
4 if c == '&':
5 ret += "&"
6 elif c == '<':
7 ret += "&lt;"
8 elif c == '>':
9 ret += "&gt;"
10 elif c == '"':
11 ret += "&quot;"
12 else:
13 ret += c
14 return ret
15
16def simpleerror(env, startreq, code, title, msg):
17 buf = """<?xml version="1.0" encoding="US-ASCII"?>
18<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
19<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
20<head>
21<title>%s</title>
22</head>
23<body>
24<h1>%s</h1>
25<p>%s</p>
26</body>
27</html>""" % (title, title, htmlquote(msg))
28 startreq("%i %s" % (code, title), [("Content-Type", "text/html"), ("Content-Length", str(len(buf)))])
29 return [buf]