I know this question revolves around questions that are quite similar (How to download file and redirect user to another webpage using flask?, Return a download and rendered page in one Flask response) but none of the answers helped.
Let me explain: the user fills a form, if the form is not correctly filled, my function refreshes the page with render_template and with the variable error now not empty. My page is now a page with details on the error. The user corrects the form, and submits again. This time, the form is correctly filled, my function does not refresh the page but sends a file. However, the red text stays on the page because I did not find a way to ALSO refresh the page with this time the variable error empty because there is no error whatsoever anymore.
I'm no expert, and maybe my error display management is not done correctly, but I have been looking for a way to make this red line with the error detail disappear for a whole week now, and the only thing I can think of would be to refresh the page with the variable error empty, which i cannot do because i'm already returning send_file.
I know we cannot do both: return send_file and return render_template, but is there a way to go around this? without refreshing the page with a link to then download the file, because that would add clicks to the user who would likely not be very happy with it.