indicoio.config.api_key = '525f16078717a430f9dac17cdc9dbaa3'
-input_error_409 = 'Input must be a JSON string. JSON objects must contain contain key text.'
+input_error_409 = 'Input must be a list of JSON objects. JSON objects must contain contain key text.'
service_error_503 = 'The sentiment analysis service is currently unavailable.'
class Sentiment_Analysis(Resource):
def get(self):
- return "POST a JSON string as content-type: application/json. JSON objects must contain key 'text'."
+ return "POST a list of JSON objects as content-type: application/json. JSON objects must contain key 'text'.", 405, {'Allow': 'GET'}
def post(self):
- if not request.json:
+ if not request.json or not isinstance(request.json, (list,)):
return abort(409, message=input_error_409)
texts = request.json
text_array = []
sentiment = value/len(text_array)
data = {'sentiment': sentiment}
return data, 200, {'Content-Type': 'application/json'}
+ #r = Response(response=json.dumps(data), status=200, mimetype="application/json")
+ #r.headers["Content-Type"] = "application/json"
+ #return r
+ #return output_json(json.dumps(data), 200, headers={'Content-Type': "application/json"})
api.add_resource(Sentiment_Analysis, '/')