Nicer formatting of status

This commit is contained in:
Tom Christie 2010-12-30 17:32:52 +00:00
parent abb55a4909
commit a78f578475
2 changed files with 4 additions and 2 deletions

View File

@ -1,4 +1,5 @@
from django.template import Context, loader
from django.core.handlers.wsgi import STATUS_CODE_TEXT
import json
class BaseEmitter(object):
@ -17,6 +18,7 @@ class TemplatedEmitter(BaseEmitter):
context = Context({
'content': content,
'status': self.status,
'reason': STATUS_CODE_TEXT.get(self.status, ''),
'headers': self.headers,
'resource_name': self.resource.__class__.__name__,
'resource_doc': self.resource.__doc__

View File

@ -10,8 +10,8 @@
<body>
<h1>{{ resource_name }}</h1>
<p>{{ resource_doc }}</p>
<pre>{% autoescape off %}HTTP Status {{ status }}
{% for key, val in headers.items %}{{ key }}: {{ val }}
<pre>{% autoescape off %}<b>{{ status }} {{ reason }}</b>
{% for key, val in headers.items %}<b>{{ key }}:</b> {{ val }}
{% endfor %}
{{ content|urlize_quoted_links }}{% endautoescape %} </pre>
</body>