If I define two functions:
def atesting():
a = 2
return a
def btesting():
b = a+ 3
return b
But in Flask I get an "Internal Server Error" when running the following if "a" hasn't been defined already. Although if I define "a" outside the app ie say a =2, then it works and I get 5.
app = Flask(__name__)
@app.route('/')
def index():
results = {}
a = atesting()
results = btesting()
return render_template('index.html', results=results)
if __name__ == '__main__':
app.run()
Index.html:
<html>
<h1>{{ results }}</h1>
</html>
But just normally in Python I get 5 when i run this:
a = atesting()
btesting()
Why won't Flask use a = atesting() as an input when computing btesting()?