keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
348 stars 138 forks source link

Openchat #212

Closed keiffster closed 5 years ago

keiffster commented 5 years ago

Updated version with v1, v2 compatibility issues solved

ohoachuck commented 5 years ago

Unless, there is a trick I haven't seen, you might have forget to remove the "status" value when in version == 2.0 ?

if version == 1.0:
    return make_response(jsonify(response_data, status))
elif version == 2.0:
    return make_response(jsonify(response_data), status)
else:
    return make_response('Invalid API version', 500)
keiffster commented 5 years ago

Subtle difference but it is correct, make_response is a flask method and is the area which I made the mistake in v1. The method takes a payload and an optional response. in v1.0 I jsonify the payload + the response, so any calls to programy always returned with HTTP 200

In version this has been corrected, I only jsonify the payload, but then use the method as per the specification to return the payload and a valid HTTP code.

Correct this means I can now return 'Invalid API version' error message with a valid 500 error code