Added a simpleerror function.
authorFredrik Tolf <fredrik@dolda2000.com>
Wed, 16 Jan 2013 00:16:25 +0000 (01:16 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Wed, 16 Jan 2013 00:16:25 +0000 (01:16 +0100)
wrw/proto.py

index 8474b3a..4cf1951 100644 (file)
@@ -85,6 +85,22 @@ def htmlq(html):
             ret += c
     return ret
 
+def simpleerror(env, startreq, code, title, msg):
+    buf = """<?xml version="1.0" encoding="US-ASCII"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US">
+<head>
+<title>%s</title>
+</head>
+<body>
+<h1>%s</h1>
+<p>%s</p>
+</body>
+</html>
+""" % (title, title, htmlq(msg))
+    startreq("%i %s" % (code, title), [("Content-Type", "text/html"), ("Content-Length", str(len(buf)))])
+    return [buf]
+
 def urlq(url):
     ret = ""
     for c in url: