Can a Dash app be hosted as a static webpage using an S3 bucket on AWS?

I know you can deploy Dash apps to AWS using Elastic Beanstalk or a simple EC2 instance. However, is it possible to host a Dash single page app as a static webpage using an S3 bucket?

I found a couple tutorials to host a Flask app as a static webpage (linked below), but was curious if it worked with Dash.

I gave it a go quickly, using the first linked tutorial, and it didn’t seem to work as expected. Before I spend time investigating, I wanted to check with others to see if that would be time well spent.

How to deploy a Flask app to AWS S3 - Medium
Serve static assets on S3 Bucket — A complete flask guide - Medium

it is not, the dash server needs to be running to serve the page and respond to callbacks.

Makes sense. Thanks for the explanation.

Hi @chriddyp
Just thought about a similar question and found this:

Clientside Callbacks

Shouldn’t it be possible with that and
This?

A little late to the game here, but we just open-sourced a package (open-dash) that extracts static files from the Dash/Flask server and prepares them for deployment to S3/CloudFront. There are two static deployment options:

  1. Applications with one static page can be deployed to S3 and CloudFront with little configuration. You can effectively skip CloudFront in this option, but it’s not recommended.
  2. Applications with multiple pages can leverage Lambda@Edge to serve requests to the /_dash-update-component endpoint, which is how the Dash server does multi-page routing. You need Lambda@Edge for multi-page applications because (a) /_dash-update-component is a POST request and S3 only serves GET requests, and (b) the URL pathname is in the POST request’s body, so you need a function to extract it.

It’s worth mentioning that this will not work if the application requires cookies to operate.

I hope that helps :slight_smile:

1 Like