I want to show a table in the html using python flask framework. I have two array. One for column heading and another for data record. The length of the column heading and data record are dynamic. I can dynamically manage the column 'headings'. But simply append information into the 'data' array is not showing the data correctly. Please help me to solve this problem. Should change something in the html file to make it dynamic? Python file from flask import Flask, request, render_template
app = Flask(__name__)@app.route('/')
def my_form():#headings = ("name", "role", "salary")headings = []headings.append("name") headings.append("role") data1 = ("rolf", "software engineer", "4500"), ("neu", "civil engineer", "1500"), ("neu", "civil engineer", "1500")
# =============================================================================data = []data.append("rolf")data.append("software engineer")data.append("neu")data.append("civil engineer")# =============================================================================print (data1)print (data)#ss = '('+'('+ "rolf"+ ','+ "software engineer" + ',' + "4500" + ')'+','+')'return render_template('table2.html', data=data, headings=headings)if __name__ == '__main__':app.run()
html file
<table>
<tr>
{% for header in headings %}<th>{{ header }}</th>{% endfor %}</tr>{% for row in data %}<tr>{% for cell in row %}<td>{{ cell }}</td>{% endfor %}</tr>{% endfor %}
</table>