Raw response in JSON debug (#211)
This commit is contained in:
parent
2ccf2e683e
commit
84dbb51de7
|
@ -23,6 +23,7 @@ class JsonViewer(FormView):
|
||||||
)
|
)
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
|
raw_result = ""
|
||||||
try:
|
try:
|
||||||
response = async_to_sync(SystemActor().signed_request)(
|
response = async_to_sync(SystemActor().signed_request)(
|
||||||
method="get",
|
method="get",
|
||||||
|
@ -31,6 +32,7 @@ class JsonViewer(FormView):
|
||||||
except httpx.RequestError:
|
except httpx.RequestError:
|
||||||
result = "Request Error"
|
result = "Request Error"
|
||||||
else:
|
else:
|
||||||
|
raw_result = response.text
|
||||||
if response.status_code >= 400:
|
if response.status_code >= 400:
|
||||||
result = f"Error response: {response.status_code}\n{response.content}"
|
result = f"Error response: {response.status_code}\n{response.content}"
|
||||||
else:
|
else:
|
||||||
|
@ -39,4 +41,5 @@ class JsonViewer(FormView):
|
||||||
# Render results
|
# Render results
|
||||||
context = self.get_context_data(form=form)
|
context = self.get_context_data(form=form)
|
||||||
context["result"] = result
|
context["result"] = result
|
||||||
|
context["raw_result"] = raw_result
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
|
@ -15,6 +15,11 @@
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{% if result %}
|
{% 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>
|
<pre>{{ result }}</pre>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in New Issue