toddbirchard / plotlydash-flask-tutorial

📊📉 Embed Plotly Dash into your Flask applications.

Home Page:https://hackersandslackers.com/plotly-dash-with-flask/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No callbacks?

nyck33 opened this issue · comments

Hey Todd, I really want to buy you coffee but please show an example with callback functions like you introduce in the tutorial but don't really get in depth.
I posted a question on stackoverflow about this: https://stackoverflow.com/questions/64151018/plotly-dash-embedded-in-flask-cannot-get-callbacks-to-work

Hi @nyck33

I was trying to achieve the same. I only included callbacks in init_dashboard like below and place the return statement at the end. Not sure this is the best practice but it worked for me. Hope this helps.

def init_dashboard(server):
    """Create a Plotly Dash dashboard."""
    dash_app = dash.Dash(
        server=server,
        routes_pathname_prefix='/dashapp/'
    )

    # Custom HTML layout
    dash_app.index_string = html_layout

    dash_app.layout = html.Div(
    .
    .
    .

    @dash_app.callback(
    .
    .
    .
    )

   return dash_app.server

@CanerIrfanoglu Thanks! I am doing multiple Dash Apps so used this repo as my template: https://github.com/jimmybow/Flask_template_auth_with_Dash