0

I am new to flask framework, what I want to do is very simple but I cant seem to find a solution online which does not use javascript (I dont know any javascript, which is why I want to avoid it for now).

I want to call python function when user presses a button.

Here is HTML button:

<input type="submit" name="A" value="submit_A">

Python code:

@app.route('/submit_a', methods=['POST', 'GET'])
def submit_a():
    if request.method == 'POST':
        # code to detect button press
        # do stuff
    return redirect(url_for('upload_page'))

Any help would be appreciated

Ach113
  • 1,775
  • 3
  • 18
  • 40
  • 3
    see https://stackoverflow.com/questions/11556958/sending-data-from-html-form-to-a-python-script-in-flask – balderman Sep 02 '20 at 11:37

1 Answers1

1

Wrap button with form:

<form action="/submit_a" method="POST">
    <input type="submit" name="A" value="submit_A">
</form>
igor87z
  • 81
  • 3