This is the "apprunner.py" of my flask
from flask import *
from flaskext.mysql import MySQL
enter code hereapp = Flask(__name__)
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = 'myPassword'
app.config['MYSQL_DATABASE_DB'] = 'myDB'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
mysql.init_app(app)
conn = mysql.connect()
cursor =conn.cursor()
cursor.execute("SELECT * from clients")
data = cursor.fetchall()
@app.route("/")
def index():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)
and this is my index.html file:
<!DOCTYPE html>
<head>
<!-- some code here-->
</head>
<body>
<div id='info_section'>
</div>
</body>
</html>
In the data variable in the "apprunner.py" file, it contains all the entries of the "clients" table as a form of tuples. What I want to do is load the clients info from the clients table into the block in the html file whose id is "info_section". How can achieve it in python?