我刚开始接触Python和烧瓶(为了树莓派)。我想要一个web应用程序,显示数据从mysql没有刷新页面我已经尝试过了
app = Flask(__name__)
app.config['MYSQL_HOST'] = 'localhost'
app.config['MYSQL_USER'] = 'root'
app.config['MYSQL_PASSWORD'] = 'raspberry'
app.config['MYSQL_DB'] = 'tesdb'
mysql = MySQL(app)
@app.route('/')
def interactive():
return render_template('interactive.html')
@app.route('/ambildata')
def ambildata():
cur = mysql.connection.cursor()
cur.execute('''SELECT*FROM contoh WHERE id = 1''')
result = cur.fetchall()
return jsonify(result = result)
在交互式.html在
^{pr2}$但是我看不到网页上的数据
目前没有回答
相关问题 更多 >
编程相关推荐