here is a dll, that can compare face distance, and the compareFace.dll, I need use callback to receive it's value now, I want use flask to wrapper it, then can visit by http and json lib= c.CDLL('comparedFace.dll') CALLBACKFUNC = c.CFUNCTYPE(None, c.c_int, c.c_char_p) lib.startComparedFace.restype = c.c_int lib.startComparedFace.argtypes = (c.c_char_p, c.c_char_p, CALLBACKFUNC) @app.route('/compare', methods=['GET', 'POST']) def test(): if request.method == 'POST': request_json = request.get_json() print(request_json) number = request_json.get('number') image01 = request_json.get('image01') image02 = request_json.get('image02') print(image01) print(image02) @c.CFUNCTYPE(None, c.c_int, c.c_char_p) @copy_current_request_context def callback(status, result_string): result_json = json.loads(result_string) distance = result_json['compareResult'] resp_data = { "number": number, "distance": distance, } print(resp_data) response = Response( response=json.dumps(resp_data), status=200, mimetype='application/json' ) return response lib.startComparedFace(b'd:/1.jpg', b'd:/2.jpg', callback) run the code, and I receive a error ValueError: View function did not return a response I know, I should write a return 'xxx' as response But, I want wait the callback function, and return response in the callback function, so how should I modify my code, thank you. Continue reading...