i have a method (matching
) that returns a JSON file. I want to return this file via a flask method.
when i do this:
@app.route('/search', methods=['POST'])
def json_example():
req_data = request.get_json()
request_text = req_data['request'] #json text that is needed as argument for calling the matching method
json_result = matching(request_text)
return json_result
i get this error:
<title>TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple,
Response instance, or WSGI callable, but it was a TextIOWrapper. // Werkzeug Debugger</title>
playing around with str(json_result
), i just get this:
<_io.TextIOWrapper name='result.json' mode='w' encoding='UTF-8'>
Also, jsonify(json_reslult)
does not work, since i have a json file and am not trying to convert a string into a json. when trying it gives:
<title>TypeError: Object of type TextIOWrapper is not JSON serializable // Werkzeug Debugger</title>
Any helpis greatly appreciated