Pretty printing requests/responses from the python requests library in Jupyter notebook.
In [1]:
# autoreload for development
%load_ext autoreload
%autoreload 1
%aimport nbrequests
import requests
from nbrequests import display_request
In [2]:
r = requests.get('http://httpbin.org/get')
display_request(r)
In [3]:
r = requests.post('http://httpbin.org/post', data='text data')
display_request(r)
r = requests.post('http://httpbin.org/post', data=b'binary data')
display_request(r)
JSON is currently renderer using Renderjson.
In [4]:
import json
r = requests.post('http://httpbin.org/post', json={"a": "b"})
display_request(r)
In [5]:
r = requests.get('http://httpbin.org/status/500')
display_request(r)