Im trying implement “Updates on Page Load” as you document says at Live Updates | Dash for Python Documentation | Plotly
Trying this python code :
import dash
import dash_html_components as html
import datetime
def serve_layout():
d = str(datetime.datetime.now())
print ""
print "SELECT * FROM ... #This SQL Query should run once! "
print "This should run ONCE every GET of browser!! ",d, " ..."
print ""
return html.H1('The time is: ' + d)
app = dash.Dash(__name__)
app.layout = serve_layout
if __name__ == '__main__':
app.run_server()
I got this on line command console:
$ python b01.py
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:07:58.632625 …
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:07:58.634538 …
- Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
- Restarting with stat
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:08:07.365613 …
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:08:07.367369 …
- Debugger is active!
- Debugger PIN: 289-950-892
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:08:48.421873 …
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:08:48.422106 …
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:08:48.422447 …
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:08:48.422617 …
127.0.0.1 - - [01/Jul/2017 22:08:48] “GET / HTTP/1.1” 200 -
127.0.0.1 - - [01/Jul/2017 22:08:48] “GET /_dash-dependencies HTTP/1.1” 200 -
SELECT * FROM … #This SQL Query should run once!
This should run ONCE every GET of browser!! 2017-07-01 22:08:48.790658 …
127.0.0.1 - - [01/Jul/2017 22:08:48] “GET /_dash-layout HTTP/1.1” 200 -
127.0.0.1 - - [01/Jul/2017 22:08:48] “GET /_dash-routes HTTP/1.1” 200 -
How to solve this? Thanks!