当前位置:网站首页>Flash return file download

Flash return file download

2022-07-06 07:51:00 nongcunqq

from flask import Flask, send_from_directory
import os
app = Flask(__name__)

@app.route("/download")
def index():
    print(os.getcwd())
    filename = "1.png"
    path = os.path.join(os.getcwd(), filename)
    return send_from_directory(path=path, directory=os.getcwd(),  filename=filename,as_attachment=True)
    # return send_from_directory(path='./upload/upload_cnews.xlsx', directory='./upload', filename='upload_cnews.xlsx',
    # as_attachment=True)

Reference resources
https://blog.csdn.net/qq_37754830/article/details/118884561

原网站

版权声明
本文为[nongcunqq]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060747393703.html