我有一個 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í)行此操作
表單提交到 python 代碼后刷新 HTML 頁面
莫回?zé)o
2023-10-20 16:30:29