Pass Variable from python (flask) to HTML in render template?

Pass Variable from python (flask) to HTML in render template?

Shouldnt 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)

As you have to pass a value using a variable you have to define it as a string like:
animal = dog
then pass it to the html template:
return render_template(index.html, value=animal)

Now, you should see the passed value in the HTML.

Pass Variable from python (flask) to HTML in render template?

Leave a Reply

Your email address will not be published. Required fields are marked *