Skip to content

Instantly share code, notes, and snippets.

@kazoo04
Created October 9, 2014 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazoo04/2cac6269d43f638b59d0 to your computer and use it in GitHub Desktop.
Save kazoo04/2cac6269d43f638b59d0 to your computer and use it in GitHub Desktop.
Mesiterror API sample
# -*- coding: utf-8 -*-
import urllib.request
import urllib.response
import json
if __name__ == '__main__':
api_url = 'http://food.kazoo04.com:8080/api/v0/upload'
img_url = 'http://www.example.com/image.jpg'
query = { 'url': img_url }
post_data = urllib.parse.urlencode(query).encode(encoding='ascii')
response = urllib.request.urlopen(url = api_url, data = post_data)
str_response = response.readall().decode('utf8')
obj = json.loads(str_response)
print(obj)
print('url = ', obj[0]['url'])
print('label = ', obj[0]['label'])
print('error = ', obj[0]['error'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment