My problem is, How to auto refresh browser when pandas dataframe will update. ? What is the easiest way ? I am practicing python for last 6 months and new in Flask and This is my first project. Please help.
This is my table.html file
<!DOCTYPE html>
<html lang="en">
<head>
<title> Table </title>
</head>
<body>
<div align="center">
<table>
<h1>
<!--Displaying the converted table-->
{% for table in tables %}
<h2>{{titles[loop.index]}}</h2>
{{ table|safe }}
{% endfor %}
</h1>
</table>
</div>
</body>
</html>
This is my main.py file
import threading
from flask import Flask, render_template
from datetime import datetime
import time as tmm
from feed_to_dash import getData
df = getData()
def get_Data():
global df
while 1<2:
t1=tmm.time()
df = getData()
print('Execution time for getData in seconds: ' + str((tmm.time() - t1)))
tmm.sleep(1)
threading.Thread(target=get_Data).start()
app = Flask(__name__)
@app.route('/')
@app.route('/table')
def table():
return render_template('table.html', tables=[df.to_html()], titles=[''])
if __name__ == "__main__":
app.run(host="localhost", port=int("5000"))
get_Data()