Completely new to Python and Flask. Trying to read from database and pass the data to Javascript. Pulling my hair out trying to get it working, as I assume it's something small
In my python script I have:
@app.route('/report')
def test():
db = get_db()
cur = db.execute('select * from emails where id=1')
emails = cur.fetchall()
print emails
return render_template('report.html', name=links, emails=emails)
and then in my javascript I have:
{% for entry in emails %}
var getEmail = {{entry.1}}
window.alert(getEmail);
emailArray.push(getEmail)
{% endfor %}
print emails is outputting [(1, u'e')], which is correct, but the window.alert is giving me "undefined". If I change it to var getEmail = {{entry.0}} it gives me the correct ID value from the database. Can anyone point me to where I'm going wrong?