Hi all,
Please see the following two simple apps using the same port:
app1.py:
#!/usr/bin/env python
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
'Group outliers by: ',
html.Div([
dcc.Dropdown(
id='group-by',
options=[{'label': 1, 'value': 'hi'}, {'label': 2, 'value': 'hello'}],
value='hello'
),
],
),
'Sample HTML'
])
app.run_server(debug=False, port= 8050, host= 'localhost')
http://localhost:8050 reflects app1. While app1 is running, I launch another app using the same port:
app2.py:
#!/usr/bin/env python
import dash
import dash_html_components as html
import dash_core_components as dcc
from dash.dependencies import Input, Output
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
'The dropdown menu is vanished',
html.Br(),
'Sample HTML'
])
app.run_server(debug=False, port= 8050, host= 'localhost')
When refreshed, http://localhost:8050 is not overwritten to reflect app2. This behavior would have been fine if we could get an error.
The question-- is it possible to raise an error from dash if the port is already in use? A way around would be to check the port at the beginning of each app:
import socket
s= socket.socket
s.connect(('localhost',8050))
# if not is use, would give `ConnectionRefusedError`
# otherwise none
Thanks!