How can I return the function text() with it's output to be viewed in html ?
my home.html in template folder:
<html>
<body>
<h2>
{% text() %}
</h2>
</body>
</html>
my app.py in root folder:
from flask import Flask, render_template
import random
app = Flask(__name__)
def text():
f = open('motivational.txt','r')
text = f.readlines()
return text[random.randrange(0,371)]
@app.route('/')
def home():
return render_template("home.html")
if __name__ == "__main__":
app.run(debug=True)
error :
File "~/templates/home.html", line 494, in template
{% text() %}
jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'text'.
thanks