I am new to flask or web applications, so I have an API running on this a virtual machine using flask, which takes an image as an input and returns the features in a JSON file. Here is the code:
`
from flask import Flask
from flask import send_file
from flask import Flask, request, send_from_directory, redirect, render_template, url_for, jsonify
import socket
import requests
import json
ip = socket.gethostbyname((socket.getfqdn()))
app = Flask(__name__)
@app.route('/')
def hello_world():
    return 'Hello, World!'
@app.route('/get_image')
def get_image():
    return send_from_directory("C:/images", "22_1.bmp")
@app.route('/goto_api')
def goto_api():
    return redirect("http://127.0.0.1/features/", code=302 )
@app.route('/post')
def post():
url = 'http://127.0.0.1/features/'
payload = {'image': 'http://127.0.0.10:6485/get_image'}
#payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"\r\n\r\nhttp://127.0.0.10:6485/get_image\r\n-----011000010111000001101001--"
headers = {'content-type': "application/json"}
response = requests.post(url, data=payload, headers=headers)
return json.loads(str(response)) #return json.loads(response)
if __name__ == '__main__':
    app.debug = True
    app.run(port=6485, host=ip)
`
when I use return json.loads(response), it returns an error: TypeError: the JSON object must be str, bytes or bytearray, not 'Response'
when I use return json.loads(str(response)) it gives the following error:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I have tried many other things as well. Please help :) Here is how output of that API looks like
    HTTP 201 Created
    Allow: GET, POST, OPTIONS
    Content-Type: application/json
    Vary: Accept
{
    "features": [
        0.0,
        0.0,
    4.321675777435303,
    1.5690128803253174,
    0.0,
    4.284165859222412,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    9.667842864990234,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    3.6376543045043945,
    3.540004253387451,
    0.0,
    0.0,
    0.0,
    0.0,
    .
    .
    .
            0.0,
    0.0,
    2.088599681854248,
    5.591969013214111,
    3.5350821018218994,
    0.0,
    0.0,
    13.648137092590332,
    0.0,
    3.5895862579345703,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.9650025963783264,
    0.0,
    0.9726126194000244,
    0.0,
    2.707155704498291,
    0.40982359647750854,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    0.0,
    5.446600437164307
]
}
 
    