mirror of https://github.com/kivy/kivy.git
Merge pull request #5061 from kivy/dessant-patch-1
doc: use httpbin.org for UrlRequest example
This commit is contained in:
commit
c9bc800b10
|
@ -29,22 +29,20 @@ to the request will be accessible as the parameter called "result" on
|
||||||
the callback function of the on_success event.
|
the callback function of the on_success event.
|
||||||
|
|
||||||
|
|
||||||
Example of fetching weather in Paris::
|
Example of fetching JSON::
|
||||||
|
|
||||||
def got_weather(req, results):
|
def got_json(req, result):
|
||||||
for key, value in results['weather'][0].items():
|
for key, value in result['headers'].items():
|
||||||
print(key, ': ', value)
|
print('{}: {}'.format(key, value))
|
||||||
|
|
||||||
req = UrlRequest(
|
req = UrlRequest('https://httpbin.org/headers', got_json)
|
||||||
'http://api.openweathermap.org/data/2.5/weather?q=Paris,fr',
|
|
||||||
got_weather)
|
|
||||||
|
|
||||||
Example of Posting data (adapted from httplib example)::
|
Example of Posting data (adapted from httplib example)::
|
||||||
|
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
def bug_posted(req, result):
|
def bug_posted(req, result):
|
||||||
print('Our bug is posted !')
|
print('Our bug is posted!')
|
||||||
print(result)
|
print(result)
|
||||||
|
|
||||||
params = urllib.urlencode({'@number': 12524, '@type': 'issue',
|
params = urllib.urlencode({'@number': 12524, '@type': 'issue',
|
||||||
|
|
Loading…
Reference in New Issue