python file pass value to html with flask
- error
Internal Server Error
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.`
import mysql.connector
# from mysql import connector
import webbrowser
import time
import pymysql
from flask import Flask,render_template
app = Flask(__name__)
mydb = mysql.connector.connect(
host="196.168.101.141",
user="root",
password="password123",
database="cool_db",
auth_plugin='mysql_native_password'
)
mycursor = mydb.cursor()
mycursor.execute("SELECT P_TITLE,P_DESC FROM webpage WHERE P_ID = 'en_1-01'")
myresult = mycursor.fetchall()
print(myresult) # does get the result I want
# but below function not send "myresult" to html successfully
@app.route('/')
def index():
return render_template("index.html", myresult = myresult)
if __name__ == "__main__":
app.run()
- index.html
<!DOCTYPE html>
<html>
<body>
<p> this is {{myresult}}</p>
</body>
</html>
I already read through the discussion how to pass data to html page using flask? and also other tutorial but not see how to solve, therefore I need a hand thanks