python - 如何在后台运行任务并在烧瓶中使用它的输出?
问题描述
我在两个不同的函数中使用这两行,它们基本上呈现一个页面并显示已传递的数据。传递的数据需要时间来创建,然后页面会一直加载,因为它正在等待创建数据的过程完成。我希望它以一种可以呈现我的 html 页面的方式工作,并且可以通过在后台运行进程来创建数据,然后由 html 页面使用。数据用于创建表格或使用 html 中的烧瓶模板显示它。
return render_template("preferences2.html", columns=column_names, data=data.head().values)
return render_template('results.html', Algorithm_used=str(Algorithm_used[algorithm]),
selected_columns=columns, time_taken=time_taken,
confusion_matrix=confusion_matrix(y_test,pred),
labels = labels, cr=classification_report(y_test, pred, output_dict=True),
accuracy=accuracy_score(y_test, pred), X_test=X_test[:5],
y_test=y_test.head().values, pred=pred[0:5])
我想到了线程,但问题是它会在没有数据的情况下呈现 html 页面,并且在进程完成后不会显示任何内容。任何帮助,将不胜感激。
解决方案
推荐阅读
- c++ - UTF-8:输入文本和硬编码之间的不同行为
- google-chrome - 在 HTML 页面中从 URL 中选择并以黄色突出显示的文本
- java - 我对编程很陌生,想知道如何在我的 GUI 上显示 JButton
- java - ByteBuddy 是否可以使用 ASM 来实现一个方法
- c - 结构数组未按预期存储数据
- reactjs - API登录反应未连接
- x11 - 从 WSL2 转发 X11 失败
- flutter - 如何将列表的元素转换为单个数字
- java - 在 Flutter 中从 Play 商店获取产品时应用内购买崩溃
- angular - 当我更改引导顺序时,为什么我的 Angular 应用程序卡在加载中?