Skip to content
Advertisement

flask: redirecting a user to a particular section of the html page

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?)

Advertisement

Answer

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.

Advertisement