dimanche 19 décembre 2021

Make a value appear in an input text with Flask

I basically have this layout:

[user_input]

[button]

[output]

With the following flask code:

@app.route("/test", methods=["POST", "GET"])
def upperCaseIt():
   theirText = str(request.form['user_input'])
   myText = theirText.upper()
   #??? request.form['output'] = myText
   return render_template("index.html")

And here's the HTML code:

<form action="uppercasify" method="post">
   <p>Enter text</p>
   <input type="text" name="user_input">
   <br>
   <input type="submit" value="Uppercasify" id="up">
   <br>
   <input type="text" name="output" readonly>

All I want is to take the text the user put in user_input (which I do successfully), turn it all to uppercase and then feed back the uppercase version to the input text "output" (set to readonly so it can't be edited).

Everything is working fine, except for displaying the uppercase text into the input text "output".




Aucun commentaire:

Enregistrer un commentaire