mirror of
https://github.com/wassname/IndicoIo-python.git
synced 2026-08-13 11:50:15 +08:00
Added api error handeling and updated docs
This commit is contained in:
@@ -28,4 +28,8 @@ def language(text):
|
||||
|
||||
data_dict = json.dumps({'text': text})
|
||||
response = requests.post("http://api.indico.io/language", data=data_dict, headers=JSON_HEADERS)
|
||||
return json.loads(response.content)
|
||||
response_dict = response.json()
|
||||
if len(response_dict) < 2:
|
||||
raise ValueError(response_dict.values()[0])
|
||||
else:
|
||||
return response_dict
|
||||
Reference in New Issue
Block a user