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

Deploy a Dash application

Hi,

I am about to deploy my application on a server, just wondering how do I configure my app, like ip address, port and something like that.

Thanks,

I’d suggest you start here:
http://flask.pocoo.org/docs/0.12/deploying/

Dash app has a flask app at its core. Go with Heroku or Elastic Beanstalk, follow a tutorial how to install a simple Flask app there, and then try with your dash app.
Or contact Plotly - surely they would be glad to help you, for a fee - this is the commercial reason why they built Dash in the first place (besides desire to improve the whole python data ecosystem).

1 Like

If you are on Digital Ocean or any other server, try this tutorial on how to serve a flask app

1 Like

Also, see the official dash deployment guide: https://plot.ly/dash/deployment

1 Like

Hello even I’m about to start my first application using Dash… I have read the documentation for running it on local machine…but couldnt get anything.

I have written my code in jupyter notebook. This is my code which is taken from Dash’s github account. I want to test run it…but I’m unsuccessful.

import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.graph_objs as go
import pandas as pd

df = pd.read_csv(
https://raw.githubusercontent.com/plotly/
‘datasets/master/gapminderDataFiveYear.csv’)

app = dash.Dash()

app.layout = html.Div([
dcc.Graph(id=‘graph-with-slider’, animate=True),
dcc.Slider(
id=‘year-slider’,
min=df[‘year’].min(),
max=df[‘year’].max(),
value=df[‘year’].min(),
step=None,
marks={str(year): str(year) for year in df[‘year’].unique()}
)
])

@app.callback(
dash.dependencies.Output(‘graph-with-slider’, ‘figure’),
[dash.dependencies.Input(‘year-slider’, ‘value’)])
def update_figure(selected_year):
filtered_df = df[df.year == selected_year]
traces = []
for i in filtered_df.continent.unique():
df_by_continent = filtered_df[filtered_df[‘continent’] == i]
traces.append(go.Scatter(
x=df_by_continent[‘gdpPercap’],
y=df_by_continent[‘lifeExp’],
text=df_by_continent[‘country’],
mode=‘markers’,
opacity=0.7,
marker={
‘size’: 15,
‘line’: {‘width’: 0.5, ‘color’: ‘white’}
},
name=i
))

return {
    'data': traces,
    'layout': go.Layout(
        xaxis={'type': 'log', 'title': 'GDP Per Capita'},
        yaxis={'title': 'Life Expectancy', 'range': [20, 90]},
        margin={'l': 40, 'b': 40, 't': 10, 'r': 10},
        legend={'x': 0, 'y': 1},
        hovermode='closest'
    )
}

if name == ‘main’:
app.run_server().

what changes should I make to this to run it on local server?

@tejas - you can save that file as e.g. app.py and then run the file with python app.py.

Could you create a new thread for the issues that you’re having running Dash? Also, please see https://plot.ly/dash/getting-started

I did it Chris…but i couldn’t open it in a browser window. A box appears
asking to open or save file and when I click open, nothing happens

@tejas - Could you please create a new Topic on this forum with this issue and a screenshot of the problem? You can click on the “+ New Topic” button here: https://community.plotly.com/c/dash

I was using ubuntu on digital ocean and this guide for flask+gunicorn was great!.
The guide from digital ocean is ok, but it’s a little old

1 Like