Show and Tell - Slapdash: Boilerplate for bootstrapping scalable multi-page Dash apps


#1

Hi everyone!

Slapdash is a project that provides a boilerplate project structure for bootstrapping scalable multi-page Dash applications. The idea is that you can clone/copy the project structure and then use that to bootstrap construction of your own app, without having to spend time on the initial scaffolding, which will often be the same across projects.

I have tried my best to use Dash and Flask best-practice and to make it easy to take advantage of some of the various neat affordances Dash provides, but it’s very much an ongoing project. I’m sure I’ll come across many ways in which the boilerplate can be improved as I use it to build out more apps.

I’ve been working on this on-and-off for a while, but I feel like it’s now in pretty good state to be “announcing”. Would love to get feedback and pull requests!


#2

Hi nedned,

This looks very neat indeed! I like the idea of building such a boilerplate.

I was trying to run the app though and the following occurred:

python run-flask.py --debug
Traceback (most recent call last):
  File "run-flask.py", line 5, in <module>
    from slapdash.app import app
  File "/home/VICOMTECH/jbruse/Documents/Slapdash/slapdash-master/src/slapdash/__init__.py", line 5
    def create_flask(config_object=f'{__package__}.settings'):
                                                           ^
SyntaxError: invalid syntax

there were some other prepended "f"s in component.py (line 50) and utils.py (lines 8, 28). Not entirely sure what’s going on there.

Thanks!
Jan


#3

I’m guessing you’re running Python 2? Slapdash requires 3.6+. I’ve just now added a note making this explicit. Sorry!

Those are f-strings, string literals that allow you to format strings using the same interface as the str.format() method. They were added in Python 3.6.

You can safely replace all f-strings with the equivalent str.format(). I think that’s probably the only Python 3 specific thing. I don’t plan to add Python 2 support as it’s end of life at the end of this year.


#4

Hi nedned,

Many thanks for your quick reply! In fact, I was using Python 3.5.2 - so all my fault. Sorry, didn’t know about those f-strings, interesting :slight_smile:
Thanks!