我有一个flask应用程序,它返回jsonify函数的输出,但是在html上显示的输出并不漂亮。我现在分析这个输出并在返回到html之前修改它。我试图迭代json输出,但它不允许我这样做。我该怎么做?在
首先是我的网页上jsonify函数的输出Prediction: Apple Cedar rust,99.6459424495697,Bell_Pepper
healthy,0.2868120325729251,Blueberry healthy,0.05757397739216685
我想要这样的东西Predictions:
Apple Cedar rust: 99.6459424495697
Bell_Pepper healthy: 0.2868120325729251
Blueberry healthy: 0.05757397739216685
下面是我的应用程序副本文件@app.route('/predict', methods=['GET', 'POST'])
def upload():
if request.method == 'POST':
# Get the file from post request
f = request.files['file']
# Save the file to ./uploads
basepath = os.path.dirname(__file__)
file_path = os.path.join(
basepath, 'uploads', secure_filename(f.filename))
f.save(file_path)
result = model_predict(file_path, model)
return jsonify(result)
return None
最后这是我的代码主.js文件
^{pr2}$