Flask returns Response in callback

I have a callback function that I want to encapsulate with Flask so that HTTP can be called. The code is as follows:

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)
    

when running, an error will be reported ValueError: View function did not return a response , which is normal. After lib.startComparedFace is running, no return is found to reply

.

I want to know, in flask, how to get me to return response, in the callback function I call instead of immediately. Thank you

Mar.10,2021

after_request learn about

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf48a0-31ef1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf48a0-31ef1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?