so I have been trying to make a website and I am encountering an issue here is my code
@app.route("/Download")
def download_final():
lol = os.environ.get("hell")
path = (f"Downloads/{lol}")
return send_file(path, as_attachment=True)
@app.route('/remove')
def remove():
os.remove("key.key")
foo = os.environ.get("hell")
os.remove(f"Downloads/{foo}")
return render_template("remove.html")
- want to download file and then redirect user to another webpage where the user can agree and remove the file from server.
So I found this
return send_from_directory() and redirect(url_for())
from here by using this method I am able to redirect but file is not being downloaded so then I noticed that when I redirect it remove those files so just to try this again I switched the path to homepage and started my website again I as getting the same issue redirect is working but file is not being downloaded