Sledro Sledro -4 years ago 191
Python Question

How to submit a flask form to a list?

I am new to Python. I have a flask form that I am submitting. When I submit the form I am trying to post the data to a list as follows:

for v in request.form.items():

This give mt he following:

[('w1', 'first'), ('w2', 'second'), ('w5', 'third'), ('w7', 'fourth'), ('w4', ''), ('w6', ''), ('w3', '')]

Where w1,w2,w3.... is the input name and first,second,third... is the data entered/submitted.

Is this tuples inside a list?

Is there a way to just output the 'data' section such as


Thanks in advance!

Answer Source

That's what items does; it iterates through the dictionary in the form of (key, value) pairs.

If you just want the values, iterate through those:

for v in request.form.values():
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download