传入文件名即可下载文件
from flask import Flask, send_file, Response, send_from_directory
app = Flask(__name__)
@app .route("/download")
def download():
"""读取本地excel文件接口"""
path = request.args["path"].replace("_","/")
with open("result/%s" % path,"rb") as f:
stream = f.read()
response = Response(stream, content_type='application/octet-stream')
response.headers['Content-disposition'] = 'attachment; filename=%s' % request.args["path"].split("_")[1]
return response