Flask文件下载--不限类型

mac2025-06-11  38

<a class="download_file" href="#">下载</a></td> $(".download_file").click(function(){ var id = *****; this.download= id ; this.href='download_file/'+id }); @app.route("/download_file/<id>") def download_file(id): file_stream = #文件流 filename = 'abc.abc' resp = Response(file_stream, content_type='application/octet-stream') resp.headers["Content-disposition"] = 'attachment; filename=%s' % filename return resp

 

最新回复(0)