Raw response in JSON debug (#211)

This commit is contained in:
Michael Manfre 2022-12-20 03:19:00 -05:00 committed by GitHub
parent 2ccf2e683e
commit 84dbb51de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -23,6 +23,7 @@ class JsonViewer(FormView):
)
def form_valid(self, form):
raw_result = ""
try:
response = async_to_sync(SystemActor().signed_request)(
method="get",
@ -31,6 +32,7 @@ class JsonViewer(FormView):
except httpx.RequestError:
result = "Request Error"
else:
raw_result = response.text
if response.status_code >= 400:
result = f"Error response: {response.status_code}\n{response.content}"
else:
@ -39,4 +41,5 @@ class JsonViewer(FormView):
# Render results
context = self.get_context_data(form=form)
context["result"] = result
context["raw_result"] = raw_result
return self.render_to_response(context)

View File

@ -15,6 +15,11 @@
</div>
</form>
{% if result %}
<p>Canonacalized Response: (view source for raw)</p>
<div id="raw-json-result" style="display: none;">
{{ raw_result|escape }}
</div>
<pre>{{ result }}</pre>
{% endif %}
{% endblock %}