Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove excessive calls to layout() #128

Merged
merged 3 commits into from
Sep 7, 2017
Merged

Remove excessive calls to layout() #128

merged 3 commits into from
Sep 7, 2017

Conversation

chriddyp
Copy link
Member

@chriddyp chriddyp commented Sep 7, 2017

fixes #116

If app.layout is a function, then it is now only called once on startup and once for the requests

@chriddyp
Copy link
Member Author

chriddyp commented Sep 7, 2017

Usage

import dash
import dash_html_components as html
import inspect

app = dash.Dash()

print('App start')


def serve_layout():
    print('Calling layout')
    return html.Div('hlo world')


app.layout = serve_layout

if __name__ == '__main__':
    app.run_server(debug=False)
$ python app_layout_function.py
App start
Calling layout
 * Running on http://127.0.0.1:8050/ (Press CTRL+C to quit)
127.0.0.1 - - [07/Sep/2017 11:26:31] "GET / HTTP/1.1" 200 -
Calling layout
127.0.0.1 - - [07/Sep/2017 11:26:32] "GET /_dash-layout HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2017 11:26:32] "GET /_dash-dependencies HTTP/1.1" 200 -
127.0.0.1 - - [07/Sep/2017 11:26:33] "GET /favicon.ico HTTP/1.1" 200 -

@chriddyp chriddyp merged commit b890bd8 into master Sep 7, 2017
@chriddyp chriddyp deleted the fix-layout branch September 7, 2017 15:37
byronz pushed a commit that referenced this pull request Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Functions running too often on page load and callback
1 participant