【发布时间】:2021-11-03 16:28:19
【问题描述】:
我希望我的服务器向用户发送文件,然后删除该文件。
问题是为了将文件返回给用户,我正在使用这个:
return send_file(pathAndFilename, as_attachment=True, attachment_filename = requestedFile)
既然返回了,我如何使用os.remove(pathAndFilename)从操作系统中删除文件?
我也试过这个:
send_file(pathAndFilename, as_attachment=True, attachment_filename = requestedFile)
os.remove(pathAndFilename)
return 0
但我得到了这个错误:
TypeError: The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a int.
【问题讨论】:
标签: python-3.x flask