I have the following code to generate randomly from the server some random value and put it both on the web page, and in a text area:
import random
@app.route("/mock_template")
def mock_template():
x = random.uniform(0,1)
return render_template("mock_template.html",x=x)
And the file "mock_template.html" contains:
{{x}}
<textarea> {{x}} </textarea>
If I go to this page, I would get some value for x, like 0.1234, both in the page and in the editable zone, which is fine. However, if I write something in the editable zone, and then refresh, the value on the page has changed (as expected), but the value in the editable zone is still 0.1234.
I understand that this behavior can be desirable if I don't want the user to lose what she has started to write before an accidental refresh, but in my case I want the new value of x to be displayed. How do I do that? (I don't care of losing the text the user has entered).