I have a very basic question (first time i use Flask, i am not used to web frameworks).
I would simply like to update variables in a template e.g. hello.html nothing else (i don't care about routes or anything at the moment)
i do that according to a tutorial:
from flask import Flask, render_template app = Flask(__name__) x=1986 res=render_template('hello.html', myVar = x) print(res) if __name__ == '__main__': app.run(debug = True) Please note that i have a html file name hello.html in a subdir called templates. hello.html:
<!doctype html> <html> <body> <h1>Hello {% print(myVar) %}</h1> </body> </html> what am i doing wrong?
edit. i get this error message:
Traceback (most recent call last): File "flask_test1.py", line 7, in <module> res=render_template('hello.html', myVar = x) File "/root/miniconda3/lib/python3.4/site-packages/flask/templating.py", line 133, in render_template ctx.app.update_template_context(context) AttributeError: 'NoneType' object has no attribute 'app' P.s. sorry about my "clumsyness" with web frameworks...