Solution 1 :

According to mdn:

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

The value will always be None

Problem :

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.


Edit: fixed formatting and grammar.

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


Comment posted by fastest mop alive

request.form[“Text”] == None? I’m assuming you have another button and you are trying to differentiate between the two submits?