I want to send and receive images in bytes in my flask API. I also want to send some json alongside the image. How can I achieve this? 

Below is my current solution that does not work 

flask: 

```
    @app.route('/add_face', methods=['GET', 'POST'])
    def add_face():
    if request.method == 'POST':
        # print(request.json)
        nparr = np.fromstring(request.form['img'], np.uint8)
        print(request.form['img'])
        img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)

        cv2.imshow("frame", img)
        cv2.waitKey(1)

    return "list of names & faces"

```

client: 

```
def save_encoding(img_file):
    URL = "http://localhost:5000/add_face"
    img = open(img_file, 'rb').read()

    response = requests.post(URL, data={"name":"obama", "img":str(img)})
    print(response.content)

```

produced error:

```
cv2.imshow("frame", img)
cv2.error: OpenCV(3.4.3) /io/opencv/modules/highgui/src/window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

```