|
In this article, we will see how to get data from ImmutableMultiDict in the flask. It is a type of Dictionary in which a single key can have different values. It is used because some elements have multiple values for the same key and it saves the multiple values of a key in form of a list. It is usually used to get the Information passed in a Form. Example: Python3
Output: ['GFG', 'Geeks For Geeks'] Now, Let’s see how to get MultiDict data from the form in Flask. With some simple HTML code to make a form and submit it to a flask route. Folder Hierarchy home.html Make Sure this file is in the ‘templates’ folder HTML
Now create an app.py Here, The home function is being used as the handler for the route, It simply renders the home.html file and when a POST at the URL. It simply returns the ‘im_dict’. It is nothing but actually, an ImmutableMultiDict which has all the data contained in the form. Python3
Output: ![]() Write anything in the fields and press submit This shows an ImmutableMultiDict with the keys ‘username’ and ‘password’. ![]()
|
Reffered: https://www.geeksforgeeks.org
Geeks Premier League |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 11 |