2

My problem is the following: i have a simple web app that requires a user to upload a file, submitting a POST request to the flask server. If the file does not match the the requirements set by the application, the user is redirected to the same html page containing a form, and a message warning the user of their mistake is flashed onto the html page.

My problem is the following: currently the form is located at the bottom of the html page, but when the user tries uploading an unsuitable picture, they are redirected to the beginning of the page. How do I tell flask to redirect the user to a specific section of the page (ie the section where the form is located in?)

Beatrix
  • 55
  • 7
  • Create e.g. a section in HTML with an unique ID: `
    ` and use `url_for(.... _anchor='my_form')`; related question is answered here: https://stackoverflow.com/q/21583594/5378816
    – VPfB Mar 07 '22 at 15:22

1 Answers1

3

you can try use id in your html simply add an id to the form then in your url add an #myFormId, if you'r using url_for do this

redirect(url_for("index")+"#myFormId")

also check this too.