我有一个flask应用程序,当用户单击索引页上的按钮时,他们会触发生成一个报告,并使用send_file()函数将其下载到浏览器中。在
每次创建和下载报告时,服务器都会停止运行,终端中会出现以下错误。它每次都需要重新启动,我不知道如何修复它。有什么想法吗?:)
烧瓶_应用程序副本文件:from flask import Flask, render_template, request, url_for, flash
import create_report
from flask_debugtoolbar import DebugToolbarExtension
from flask import send_file
app = Flask(__name__)
filename = ""
@app.route("/")
def index():
return render_template("index.html")
@app.route("/handle_data", methods=['GET', 'POST'])
def handle_data():
text = request.form['accountinput']
preprocessed_text = text.lower()
filename = create_report.start_script(preprocessed_text)
path = "reports/" + filename
return send_file(path, as_attachment=True)
if __name__ == '__main__':
app.run(debug=True)
终端错误:
^{pr2}$