def get(word): try: service = WordClassificationService() entity = service.find_one(word) if not entity: raise ValueError( 'WordClassificationService did not return a result') return jsonify({'word': word}), HTTPStatus.OK except ValueError as err: return jsonify('Word [' + word + '] not found: ' + repr(err)), HTTPStatus.NOT_FOUND except Exception as err: return jsonify('Internal server error: ' + repr(err)), HTTPStatus.INTERNAL_SERVER_ERROR
def get(word): response = None if request.is_json: try: service = WordClassificationService() # Execute analysis using the supplied builder entity = service.find_one(word) if not entity: raise ValueError('WordClassificationService did not return a result') payload = jsonpickle.encode(entity) response = make_response(payload, HTTPStatus.OK) except Exception as error: print('Error: ' + repr(error)) raise else: response = make_response(HTTPStatus.BAD_REQUEST) return response