Hello guys, small part of my code here, i have result and pred variables. And in the html part i have this code:
<div style = "margin-Top:100px;" >
{{ results[pred] }}
</div>
And i get this error. So how can i fix it? So i thought the variable in html calling like that in flask. Am i wrong?
CodePudding user response:
You can’t pass parameter like this.
In render_template pass result=result
And then in the template you can use it like you write - result[pred]
CodePudding user response:
results[pred]
uses 2 variables to resolve:
- results, dict
- pred, the lookup in the dict
It seems, that u only need the value of pred in results. You can do this by using return render_template('index.html', var=results[pred])
and {{ var }}
Edit: In your case pred is static in python so you should only return the mandotory value of the results dict to the template.