The web server works (python flask) but when I go to the website, where the value of animal should be (dog) it shows the variable name animal. (There is more to the code but this is the most simplistic version which is the same concept.
Let's say I have these lines of code in my python script running python flask.
animal = dog return render_template('index.html', value=animal)
and in my HTML
<h3>I like the animal: {{ value }}<h3>
but rather than displaying 'dog' it displays the variable name 'animal'. So how would I go about displaying the Python variable to HTML? Thank you
To pass variables from Python Flask to JavaScript, we can call render_template with the data argument with the dictionary of data we want to pass to the template. to call render_template with the template file name and the data set to the data dict with the data we want to pass to the template.
Solution. In email. html change {{userEmail}} to {userEmail} . Then you should be able to use Python string formatting to add the userEmail variable.
Shouldn't it be animal = 'dog'
? If 'dog' is the value you want to see printed after "I like the animal:", this is what you need to do:
animal = 'dog' return render_template('index.html', value=animal)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With