Python Flask – ImmutableMultiDict
MultiDict is a sub-class of Dictionary that can contain multiple values for the same key, unlike normal Dictionaries. It is used because some form elements have multiple values for the same key and it saves the multiple values of a key in form of a list.
GFG ['GFG', 'Geeks']
In this article, we will see how to get MultiDict data from the form in Flask.
Let us write a simple HTML page with a form tag and submit it to a flask route. The request.form object which is used to get the contents from the form during POST request is of type ImmutableMultiDict.
Let us write another HML file that will shoe the type of the data given by the POST request.
Creating Flask app
We will create a simple flask app that will render the above-created form at the URL http://127.0.0.1:5000/input and will show the data submitted using the POST request at the URL http://127.0.0.1:5000/save