Creating and Running a Simple App
Explore how to create and run a basic Dash app by writing your app.py file, setting up the app layout with HTML components, and running the app with debugging enabled. This lesson helps you understand the core building blocks of a Dash app, including managing layout elements and using key HTML parameters to structure your app's interface.
We'll cover the following...
We'll cover the following...
Let’s build our first simple app! We’ll start with the app.py file.
Steps to create and run the app
Create a file, name it app.py, and write the following code:
- Lines 1–2: We import the required packages using their usual aliases.
- Line 3: We instantiate the app.
- Lines 4–6: We create the app’s layout. This app’s layout contains one element—the list passed to
html.Div, which corresponds to itschildrenparameter. This will produce anH1element on the page. - Lines 7-8: We run the app. Note that we set
debug=Truein theapp.run_servermethod. This activates several developer tools that are really useful while developing and debugging.
Running example
We’re now ready to run our first app. Go ahead and click the “Run” button. You should now see an output like the one shown in the illustration below, which ...