From 6aa507bdd8117c80d1c5032258af2326f6a1a5ca Mon Sep 17 00:00:00 2001 From: dessant Date: Fri, 17 Mar 2017 12:46:04 +0200 Subject: [PATCH] doc: use httpbin.org for UrlRequest example --- kivy/network/urlrequest.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/kivy/network/urlrequest.py b/kivy/network/urlrequest.py index e90fb6446..900332818 100644 --- a/kivy/network/urlrequest.py +++ b/kivy/network/urlrequest.py @@ -29,22 +29,20 @@ to the request will be accessible as the parameter called "result" on the callback function of the on_success event. -Example of fetching weather in Paris:: +Example of fetching JSON:: - def got_weather(req, results): - for key, value in results['weather'][0].items(): - print(key, ': ', value) - - req = UrlRequest( - 'http://api.openweathermap.org/data/2.5/weather?q=Paris,fr', - got_weather) + def got_json(req, result): + for key, value in result['headers'].items(): + print('{}: {}'.format(key, value)) + + req = UrlRequest('https://httpbin.org/headers', got_json) Example of Posting data (adapted from httplib example):: import urllib def bug_posted(req, result): - print('Our bug is posted !') + print('Our bug is posted!') print(result) params = urllib.urlencode({'@number': 12524, '@type': 'issue',