comparison lib/cycloneerr/cycloneerr.py @ 769:71e8ab109f5a

py3 Ignore-this: fd41253efc73d29e56aa5c3b0f2fb34f
author drewp@bigasterisk.com
date Thu, 14 May 2020 22:29:44 -0700
parents 11e090ba2731
children
comparison
equal deleted inserted replaced
768:c8763fc21a42 769:71e8ab109f5a
1 try: 1 try:
2 import http.client as httplib 2 import http.client as httplib
3 except ImportError: 3 except ImportError:
4 import httplib # type: ignore 4 import httplib # type: ignore
5 import cgi 5 import html
6 6
7 class PrettyErrorHandler(object): 7 class PrettyErrorHandler(object):
8 """ 8 """
9 mix-in to improve cyclone.web.RequestHandler 9 mix-in to improve cyclone.web.RequestHandler
10 """ 10 """
15 tb = "" 15 tb = ""
16 return "<html><title>%(code)d: %(message)s</title>" \ 16 return "<html><title>%(code)d: %(message)s</title>" \
17 "<body>%(code)d: %(message)s<pre>%(tb)s</pre></body></html>" % { 17 "<body>%(code)d: %(message)s<pre>%(tb)s</pre></body></html>" % {
18 "code": status_code, 18 "code": status_code,
19 "message": httplib.responses[status_code], 19 "message": httplib.responses[status_code],
20 "tb" : cgi.escape(tb), 20 "tb" : html.escape(tb),
21 } 21 }