This commit is contained in:
Marko Tibold 2011-12-30 18:52:15 +01:00
parent e82ab8ea31
commit e44f182fcf

View File

@ -4,15 +4,15 @@ Using urllib2
Python's standard library comes with some nice modules Python's standard library comes with some nice modules
you can use to test your api or even write a full client. you can use to test your api or even write a full client.
Here's an example which does a 'GET' on the `model-resource` examle Here's an example which does a 'GET' on the `model-resource` example
in the sandbox.:: in the sandbox.::
import urllib2 >>> import urllib2
>>> r = urllib2.urlopen('htpp://rest.ep.io/model-resource-example') >>> r = urllib2.urlopen('htpp://rest.ep.io/model-resource-example')
# You can check if the response was ok: # You can check if the response was ok:
>>> r.getcode() >>> r.getcode()
200 200
# Or examin the resonse itself: # Or examin the response itself:
>>> print r.read() >>> print r.read()
[{"url": "http://rest.ep.io/model-resource-example/1/", "baz": "sdf", "foo": true, "bar": 123}] [{"url": "http://rest.ep.io/model-resource-example/1/", "baz": "sdf", "foo": true, "bar": 123}]