【发布时间】:2014-10-05 04:23:48
【问题描述】:
我想每 5 秒更新一次模板查询,但对于每种情况我都得到相同的值。如何每 5 秒保持刷新和检索值? 我想实现监控脚本每 5 秒查询一次我的数据库。
@app.route('/')
def index():
while True:
conn = MySQLdb.connect(host=host,
user=username,
passwd=password,
db=database,
port=port)
df = sqlio.read_sql(qry1, conn)
value = df['id'][0]
print value
conn.close()
time.sleep(5)
return render_template('index.html', thev=value)
if __name__ == '__main__':
app.run(
port=8001,
host='0.0.0.0'
)
【问题讨论】:
标签: python pandas flask jinja2