How to display a HTML file and text with flask python


I am trying to make a website that displays text I can change (preferably instantly).
I was able to do this with:

def index():
    global val
    return str(val)

along with a function running at the same time allowing me to change the variable "val"

However, now I would like to be able to display data and receive data from the user. To do this I used an HTML template, however I am not able to instantly change the data in the HTML file, so I can not change the data easily.

def index():
    return render_template('form.html')

I would like to be able to display this HTML template, and the variable "val" at the same time.
I have tried:

def index():
    global val
    return str(val), render_template('form.html')

But this also does not work and it gives an error.

Asked By: Martin



In render_template("form.html" , str=str)

And in form.html


This way using jinja syntax you can display the variable

thank you

Answered By: Hariharan
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.