I want to change the value of a button written in html to "records". I want to adress and change the button in python. This is in order to prevent to tap the record button twice as the request form changes and to get a visual feedback that it works.
this is what i have:
@app.route('/camera', methods=['GET', 'POST'])
def camera():
if request.method == 'POST':
if request.form['record'] == 'record here' : # <-------- here I ask what the value of the button
print ("is recording") # is and it works fine
p1 = threading.Thread(target=recording)
p1.start()
return render_template('camera.html')
this is what i want:
@app.route('/camera', methods=['GET', 'POST'])
def camera():
if request.method == 'POST':
if request.form['record'] == 'record here' :
print ("is recording")
p1 = threading.Thread(target=recording)
p1.start()
request.form['record'] = 'records' : # <----------------- Something like this
return render_template('camera.html')
I am a newbie in python html flask and web development in general.
2
Answers
What you are looking to do should be done through JavaScript, because the most natural way to change the label of the button is through client-side programming.
However, if you insist on doing this from server-side code, you can start by changing the template
camera.html
. Let’s say that you have the following button in your template:This should be changed to include a variable:
Now you can send the value of this variable using
render_template
:What I noticed from your code is that you want to change the value of a button in camera.html page to ‘records’.
To do so, you should pass ‘records’ as an argument to render_html and receive it in camera.html and assign it to the button’s value.
Now in your camera.html you have a, say button or input, with a name ‘records’: