我正在尝试写入o_filename,以使用户从我的flask Web页面下载它。
if request.method == 'POST':
# user wants to download from s3
# user wants to hydrate
if 'hydrate' in request.files:
file = request.files['hydrate']
if file and allowed_hydrate_file(file.filename):
filename = secure_filename(file.filename)
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
o_filename = filename
o_filename = o_filename[:-3]
o_filename += "jsonl"
fileWrite = open(o_filename,"w")
fileWrite.write("reddit")
print("here")
file.save(os.path.join(app.config['UPLOAD_FOLDER'], o_filename))
return send_from_directory(app.config['UPLOAD_FOLDER'],
o_filename, as_attachment=True)
现在,用户应该可以下载带有文本“ reddit”的o_fileanme。该代码使用户可以下载o_filename,但是该文件为空。我知道这不是正确的jsonl格式,但是我正在测试。我在做什么错,为什么文件为空?