With this line of code in python I created JSON containing multiple messages:
notification = [{
'message': 'This is the homepage',
'username': 'User',
'room': 'Home',
'timestamp': '11:59'
},
{
'message': 'Hello World!',
'username': 'User',
'room': 'Home',
'timestamp': '12:00'
}]
return render_template("chat.html", messages = notification)
Now I would like to print all the messages on the webpage, so I sent all the information to javascript. But when the output of the following script returns an empty string.
const message = `{{messages}}`;
console.log(message);
Why is the string empty?
render_templateis a flask function. I don't know about the rest of the file. Also the script is probably embedded into the HTML. I just assumed it was, my bad.{{messages}}?