from ipyrest import Api
url = 'https://xkcd.com/552/info.0.json'
Api(url)
import requests
from ipyrest import Api
url = requests.get('https://xkcd.com/552/info.0.json').json()['img']
Api(url)
import requests
from ipywidgets import Image
from ipyrest import Api
from ipyrest.responseviews import ResponseView, builtin_view_classes
class XKCDView(ResponseView):
"Api rendering view for XKCD comics taken from XKCD JSON API."
name = 'XKCD'
mimetype_pats = ['application/json']
def render(self, resp):
return Image(value=requests.get(resp.json()['img']).content)
url = 'https://xkcd.com/552/info.0.json'
Api(url, views=builtin_view_classes + [XKCDView])
url = 'https://xkcd.com/info.0.json'
Api(url, views=builtin_view_classes + [XKCDView])
Compare with xkcd.com...