Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8013

Beginners • Re: Trouble with Flask

$
0
0

Code:

    templateData = {              'title' : 'GPIO output Status!',              'ledRed'  : ledRedSts,              'temperature'  : tempSts,          }    [code]return render_template('index2.html', **templateData)
[/code]
You have to pass a variable to your template, which jinja then uses to fill in the extracted information. Since templateData is a dict, there is no need to pass it as **kwargs. Jinja doesn't work well with kwargs anyway ;-) Try this ( I' haven't):

Code:

   templateData = {              'title' : 'GPIO output Status!',              'ledRed'  : ledRedSts,              'temperature'  : tempSts,          }    return render_template('index2.html', data = templateData)
And in index2.html, insert like this:

{{ data['title'] }}
{{ data['ledRed'] }}
{{ data['temperature'] }}

Note that I changed the variable on purpose to show which one is used in the template. You often see the following to keep the same variable names:

Code:

return render_template('index2.html', templateData = templateData)

Statistics: Posted by kheylen25 — Sun Mar 03, 2024 8:50 am



Viewing all articles
Browse latest Browse all 8013

Trending Articles