<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Students Record</title>
</head>
<body>
<h2>School Grading System</h2>
<hr/>
<a href="/student">Students</a> |
<a href="#">Subjects</a> |
<a href="#">Instructor</a> |
<a href="#">Score Sheet</a>
<hr/>
<h2>See Student Record</h2>
<a href="/">Back to home</a><br/>
<table width="100%" border=1>
<tr>
<th>Id</th>
<th>Surname</th>
<th>Othernames</th>
<th>Address</th>
</tr>
{%for rec in students%}
<tr>
<td>{{rec[0]}}</td>
<td>{{rec[1]}}</td>
<td>{{rec[2]}}</td>
<td>{{rec[3]}}</td>
</tr>
{%endfor%}
</table>
</body>
</html>
from flask import Flask, render_template, request
import sqlite3, os
app = Flask(__name__)
#get the current path name our app
dir_path = os.path.dirname(os.path.realpath(__file__))
#create and connect to the database in our current folder
conn = sqlite3.connect(dir_path+'/tealearn_grades.db', check_same_thread=False)
#.....
#view students record
@app.route('/seestudents')
def seestudents():
cursor = conn.cursor()
cursor.execute('SELECT * FROM student')
data = cursor.fetchall()
return render_template('seestudents.html', students=data)
#.....
if __name__ == '__main__':
app.run(debug=True)
No Comment yet!