What is necessary to get a button on a webpage work with flask? I just want to turn a LED on.
the html looks like:
<tr>
<td><h3>Computer</h3></td>
<td><p><input type="submit" name="btnled" value="ON"></p></td>
<td><p><input type="submit" name="btnled" value="OFF"></p></td>
</tr>
How can i catch the pressed button in python to turn the led on? What do i need? WTForms?
Edit:
the .py looks like this:
from flask import request
@app.route("/switch_led", methods=['POST'])
def led_handler():
if request.form['btnled'] == "ON":
print("ON")
elif request.form['btnled'] == "OFF":
print("OFF")