Deploy dash app to aws ec2

Evening!
I’m struggling a bit on how to deploy my app. I’m new to flask and WSGI and despite my best attempts to understand the docs, i’m completely lost.

I have an a single app.py file that contains the layout, callbacks, everything. I’m trying to figure out how to package this up and deploy it to an aws ec2. What is the best practice way to do this?

i removed the

if __name__ == '__main__':
    app.run_server(debug=True)

from the bottom of my app.py file which is correct for deployment right?

Thanks for the help!

Anyone have any suggestions on this?

Thanks!

Hey bro,

What you did ?!

@kabure A lot actually. It took me a bit to figure out and i wound up packing my program up into docker and then deploying it through AWS ECS fargate which once you get it all stood up is actually really easy to maintain. My suggestion is to get your program working without this first then add this deployment pipeline in. You may also find it easier to use heroku since it ties almost directly in with dash/plotly.

Now from a dash/plotly perspective, they’ve since updated their user guides for multipage app so its a little easier to understand now.

I set up an app.py file:

import dash
import flask
import dash_bootstrap_components as dbc

app = dash.Dash(__name__, suppress_callback_exceptions=True)

and then in each of my py files (each of my files is a single page in my app), i added:

from app import app
server = app.server

This allows the program to use the same app and avoids circular references. Plotly explains is pretty well here: URL Routing and Multiple Apps | Dash for Python Documentation | Plotly