我有使用 Electron.js 作为 gui 的 python 应用程序,该程序从 html 获取文件夹名称并发送到 python。在 python 脚本中,它读取每张照片并检测它们。
但在每次迭代中,我无法将它们发送到 html。
我如何将每张照片的结果发送到 html。
@app.route("/Multi", methods=["GET", "POST"])
def multiPlantAlaysis():
if request.method == "GET":
print("gete griddd")
return render_template("MultiGrapeAnalysis.html")
if request.method == "POST":
path = request.form["path"]
data_path = os.path.join(path, '*g')
files = glob.glob(data_path)
data = []
acc5 = []
classes2 = []
for f1 in files:
img = cv2.imread(f1)
name = str((f1))
accuracies, classes =
PredictGrape(name,classifierGrape,ResultArrayGrape)
return render_template("xyz.html", preds=accuracies,
classes=json.dumps(classes )
它只发送其中一个。我知道因为 return 声明它做到了。但是有没有办法做到这一点?
编辑
我创建了一个数组,我将每个结果添加到数组中并使用 html 返回它们。但是问题在于,如果文件夹 gui 中的图像超过 20 个,则等待大约 1 分钟。因此我需要将每个结果传递给 html。怎么能做到这一点?