Black Lives Matter. Please consider donating to Black Girls Code today.

Find if dash is up

Hi,
is there any way for the client to know if the dash app is still running - without refreshing the page?

I tried using this code - but it doesn’t seem to work and change the color after I bring the app down:

<…>
def isOpen(ip,port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, int(port)))
s.shutdown(2)
return True
except:
return False
<…>
@app.callback(Output(‘title’, ‘style’),
[Input(‘interval-component’, ‘n_intervals’)],
[State(‘title’, ‘children’)])
def update_style(n,current_state):
if n>0:
if not(n%3):
if isOpen(‘127.0.0.1’,8050):
return current_state
else:
return {‘color’: ‘red’}
else:
return current_state
else:
return {‘color’: ‘black’}

When I check the port from another python console - the function do show true/false when the app is up/down

Use hot-reload, when it fails to reload it will send you an alert.

Thanks, but this does not help me. I would like to present a message on the client side - that the app is not working.