Flask Programming

Hands On No. 6 : Working With Lists

Resources

Source Code of hello.py
from flask import Flask
from flask import render_template

app = Flask(__name__, template_folder='templates')
    
@app.route('/')
def listfiles():
    studentdata = [[1,"Vraj","Ahmedabad"],[2,"Dev","Vadodara"],[3,"Dhruvit","Jamnagar"]]
    return render_template('View-Data.html', studentdata=studentdata)

Source Code of View-Data.html

<!DOCTYPE html>
<html>
<head>
<title>Student Data</title>
</head>
<body>
<table width="500px" align="center">
<tr>
<td>Student ID</td>
<td>Student Name</td>
<td>City Name</td>
</tr>
{% for a1,a2,a3 in studentdata %}
<tr>
<td>{{ a1 }} </td>
<td>{{ a2 }} </td>
<td>{{ a3 }} </td>
</tr>
{% endfor %}

</table>
</body>
</html>