Update Javascript with results from Python script.
I want to update my Javascript script with Python script in Flask
.
I get a value from my Python
script, and want to pass it to or update Javascript.
But can 't figure out how in Flask
.
The following is my Javascript that I need to update:
events: {
load: function() {
// set up the updating of the chart each second
var series = this.series[0];
setInterval(function() {
var x = (new Date()).getTime();
// Value from Python script (DataFrame)
var y = Math.random() * 100;
series.addPoint([x, y], true, true);
}, 5000);
}
}
Here, I am passing random values but I want to pass the value from my Python script. My Python script would be like the following:
import MySQLdb
import pandas.io.sql as sqlio
host = "~~~" # Public
port = 1111
username = "aa"
password = "aaa"
database = "aaaa"
conn = MySQLdb.connect(host=host,
user=username,
passwd=password,
db=database,
port=port)
qry1 = """
~~
"""
df = sqlio.read_sql(qry1, conn)
df['count'][0] # return some number in Python
function members. I know you won' have get