简体   繁体   中英

How To Get image <input> from HTML in flask

Quick question as I can't really find this anywhere else.

If I had an input that is formed like this:

<input type="image" name="Text" value="text" src="{{ url_for('static', filename='images/icons/General/Post.svg') }}" />

How Can I retrieve this being pressed with request.form[] ?

I get an KeyError with the following:

if request.method == "POST":
    if request.form["Text"] == "text":
        return render_template("PostText.html")

I know there is a similar way of retrieving data using <input type="submit" value="text"> but it doesn't work with the former.

Thanks!

Edit: fixed formatting and grammar.

TLDR: I can't detect an input with the type of image from flask in python.

According to mdn :

for input elements of type image the value attribute should not be specified

The value will always be None

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM