I am trying to display data from the SQL table onto the html page
My data is a MEDIUMBLOB type data
main.py
@app.route("/text")
def text():
def generate():
if 'name' in request.form:
cursor = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
name = request.form['name']
here = cursor.execute("SELECT transcript from `movies` WHERE movie_name = %s",[name])
with open(here) as f:
f.read()
return app.response_class(generate(),mimetype='text/plain')
view.html
<div class="top">
<h1>APPLES</h1>
</div>
{% block content %}
<div class="scontainer">
<div id="list">
<iframe src="/text" height="400" width="600"></iframe>
</div>
</div>
{% endblock %}
</body>
</html>
I tried this but I could not get the results that I was looking for.
It just turns up blank like the image shown below
Problem image
2
Answers
Just return the content of
f.read()
from yourgenerate()
function.I have updated the answer. Change your code as the following.
and your view.html: