Here is my code in app.py:
from flask import Flask, render_template, request, g
import sys
import sqlite3
import os
current_directory = os.path.dirname(os.path.abspath(__file__))
app = Flask(__name__)
@app.route('/student')
def student():
connection = sqlite3.connect(current_directory + "/sss.db")
cursor = connection.cursor()
Lastname='Volley'
Firstname='Vlad'
result = cursor.execute("SELECT * FROM Students WHERE Firstname=? AND Lastname=?", (Firstname,Lastname))
result.fetchone()
res = list(result)
connection.commit()
connection.close()
return render_template('student.html', res=res)
if __name__ == "__main__":
app.debug=True
app.run(port=3000)
Additionally - in student html file - I'm trying to display the data just to ensure its there.
As you can see from the app file I'm converting the results from the query to a list. That way I can visualize it on the student html page, however it always returns an empty list.
Data is in the sqlite3 database.
Students HTML Code Snippet below:
<div>
<div class="container mr-t">
<h1>Is this You?</h1>
<div class="container">
<p>{{res}}</p>
</div>
<form id="emailForm">
<button type="submit">Find Email and Password</button>
<button style="background-color: red;" type="submit">Clear</button>
</form>
<p id="result"></p>
</div>
</div>
