第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

表單提交到 python 代碼后刷新 HTML 頁面

表單提交到 python 代碼后刷新 HTML 頁面

莫回?zé)o 2023-10-20 16:30:29
我有一個 HTML 代碼,其中有一個“下載”按鈕,可以通過 GET 將文件下載到 python 代碼,問題是該頁面的刷新率為 5 秒,并且運行良好,但是一旦我單擊下載按鈕文件下載完畢后,頁面停止刷新。我能做什么來修復(fù)它?HTML:<html><meta http-equiv="refresh" content="5"><style>mark {       background-color: grey;        color: white;}</style><title>{{client}}</title>                <form target="_parent" method="get" action="download_file" style="display: inline;">        <h4><mark>{{client}}</mark></h4>                        <br>                        <br>                        <button  onclick="openNav()">download</button>                    <input type=hidden name="client" value="{{client}}">                    <input type=hidden name="reason" value="{{reason}}">        </form>    </body>    <script>function openNav() {      document.getElementById("myNav").style.width = "100%";    }    </script>    </html>Python:@app.route("/download_file", methods=["GET"])def download_file():#a lot of code to get the file    response = flask.Response(output, mimetype="zip", headers={"Content-disposition":"attachment; filename="+  randomName + ".zip"})    return response已嘗試添加onclick按鈕,但"window.location.reload();"不執(zhí)行任何操作,它會等到文件下載完成并且頁面失去刷新選項,直到我在頁面上使用 F5 手動執(zhí)行此操作
查看完整描述

1 回答

?
婷婷同學(xué)_

TA貢獻(xiàn)1844條經(jīng)驗 獲得超8個贊

更改按鈕:

<button  onclick="openNav()">download</button>

到:

<button onclick="window.setTimeout(function () {  window.location.reload();}, 10000)">download</button>

為我解決了。我刪除了

<meta http-equiv="refresh" content="5">

因為我需要在表單提交后刷新頁面


查看完整回答
反對 回復(fù) 2023-10-20
  • 1 回答
  • 0 關(guān)注
  • 132 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號