首页 > 解决方案 > 使用发送将引导按钮链接到 Flask 中的 url

问题描述

我的代码是这样的

@app.route("/mcap_format/<mcformat>")
def mcap_format(mcformat):
    return send_from_directory(app.config["mcap_format_loc"],filename=mcformat,as_attachment=False)

当我打开时,这很好用。/mcap_format/mcformat ,文件被下载。但是,当我将其链接到按钮时,它会失败。

html代码在这里

<div class = "col-md-3">
<button type="button" id = "cmap_download" onclick = "window.location.href= '{{ url_for('/mcap_format',filename = 'mc1.xlsx')}}';" data-toggle="button" class="btn btn-primary btn-sm" >Downlaod the format<!/button>
 </div>

它不工作的任何原因?

标签: flask

解决方案


推荐阅读