Skip to content

Commit

Permalink
[ESN-2880] Update Python API example to python3 (OpenGov-OpenData#4)
Browse files Browse the repository at this point in the history
* Update API pythoon example to python3

* Update sample Python Example based on feedback

changed import to urllib.request and included json library to easier parse response

* Fix indentation

Co-authored-by: Jay Guo <[email protected]>
  • Loading branch information
javier-tello and jguo144 authored Mar 2, 2021
1 parent 691fd75 commit b334ee1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions ckanext/odata/templates/ajax_snippets/api_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,13 @@ <h3>
<div id="collapse-python" class="accordion-body collapse">
<div class="accordion-inner">
<pre>
import urllib
import json
import urllib.request
url = '{{ h.url_for(qualified=True, controller='api', action='action', ver=3, logic_function='datastore_search', resource_id=resource_id, limit=5) + '&q=title:jones' }}' {# not urlencoding the ":" because its clearer #}
fileobj = urllib.urlopen(url)
print fileobj.read()
</pre>
fileobj = urllib.request.urlopen(url)
response_dict = json.loads(fileobj.read())
print(response_dict)
</pre>
</div>
</div>
</div>
Expand Down

0 comments on commit b334ee1

Please sign in to comment.