Best web framework for Dash integration

Hello everyone, I’m gonn start a new project that involves building a website in Python. I would like this website to have proper integration with Dash such that I can showcase visualizations and analysis for other people to see.

Is Flask or Django the way to go or not at all? What framework would allow for the least painful integration of Dash in my website?

Thanks

What do you mean by “proper integration”?

There’s only so much that you’ll be able to achieve as far as integration with the front-end side of the app. If you go with Flask, then it’s easy to piggyback the Dash app off the Flask app you create and mount the Dash app at a specific route prefix. But you can get a similar outcome with only a bit more effort by combining arbitrary WSGI apps (which is essentially all Python web frameworks) by using werkzeug’s DispatcherMiddleware. (hopefully we’ll get documentation on these soon)

A lot of people look for integration with Dash at the template level (eg Jinja2), but that doesn’t really make sense, as Dash apps are React on the frontend, templates handled by Python are on the backend. Building out new Dash components (or forking existing React components) is a better place to look for tighter integration of the front-end side of the app.

So on the backend, Flask is a fine choice, but if other candidates are compelling for whatever reason, then it may be worth just going with them.

I meant that it’d be painless to use Dash within my website and that I wouldn’t need to hack solutions around which I’m might not have the skills to do.

I’m much more familiar with Python than with anything else so that’s why it seemed ot be the way to go but I’m willing to learn ofc.

Do you mean I should use Flask for the back-end and React.js for the frontend? The project would relatively self-contained, some EDA and data visualization.

It will be fairly painless to embed Dash within a website running on a different Python web framework (either sitting on a specific URL as I mentioned, or just within a plain old iframe). You might get some better integrations with Flask, via Flask extensions, but again, it depends on what you mean by “use Dash within your website”.

Do you mean I should use Flask for the back-end and React.js for the frontend? The project would relatively self-contained, some EDA and data visualization.

Sort of, but not quite. You should only turn to developing you’re own Dash components once you’ve identified that the functionality you need isn’t found in existing components. Dash’s compelling advantage is that it allows you to build expressive client-side web apps using Python (and therefore on the backend). It could be worth working out if you even need another web framework. You could start by seeing how much of your entire site/app you can build in Dash.

Could a blog-like website be built entirely in Dash? I didn’t consider that but that’s quite interesting if possible.

Otherwise I’ll probably start with something easy in Flask, thanks for the explanations!

It certainly could. The Dash Guide, for example is a Dash app. I’ve been thinking about doing this myself. However there’d be some challenges to work through, and you won’t find as much documentation around those facets, whereas there’s heaps of documentation and tutorials on using Django and Flask etc for creating blog-like apps.

Thanks for the explanation, I’ll probably give it a try then!

1 Like