You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-16
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,12 @@
1
-
# NanoDash Tutorial Exercises
1
+
# Welcome to the NanoDash tutorial!
2
+
3
+
This tutorial will demonstrate how interactive web dashboard frameworks like Plotly Dash work, by building a simplified version of Dash itself from scratch using Python, the Flask framework, and a little bit of vanilla JavaScript.
4
+
5
+
## Setup
6
+
7
+
If you haven't already, please complete the setup instructions outlined in [SETUP.md]((https://github.com/plotly/tutorial-nanodash/blob/main/SETUP.md)) before continuing.
8
+
9
+
## Exercises
2
10
3
11
The 7 exercises to be completed for this tutorial are located in the directories `exercise1/` through `exercise7/`.
4
12
@@ -7,19 +15,20 @@ Each exercise folder contains the following:
7
15
- A partial copy of the NanoDash codebase (under `exerciseN/nanodash/`), containing one or more spots for you to "fill-in-the-blanks" by implementing part of the NanoDash logic
8
16
9
17
- A sample app (`exerciseN/app.py`) which will run correctly once the exercise has been completed
18
+
- To run the app from the repository root: `python exerciseN/app.py`
10
19
11
20
- A tests file (`test_exerciseN.py`) which will pass once the exercise has been completed.
12
21
- To run the tests for exercise N from the repository root: `python -m pytest exerciseN/`
13
-
- To run the tests for exercise N from within the exercise directory: `python -m pytest`
14
22
15
-
## Note on Running Pytest
16
-
We recommend running `python -m pytest` rather than just `pytest`, because it ensures using the python in your virtual environment rather than the system python.
23
+
## A note on running Pytest
24
+
We recommend using the command `python -m pytest` rather than just `pytest`, because it ensures using the Python in your virtual environment rather than the system Python.
17
25
18
26
## Exercise outline
19
27
20
28
Each exercise focuses on implementing a specific part of the NanoDash framework.
21
29
22
30
### Exercise 1: Making a basic Flask server which serves a static HTML page
31
+
---
23
32
24
33
**Goal**: Set up a simple Flask server that serves one static HTML page.
25
34
@@ -32,42 +41,45 @@ Each exercise focuses on implementing a specific part of the NanoDash framework.
32
41
**Command to run tests**
33
42
`python -m pytest exercise1/`
34
43
35
-
### Exercise 2: Implement UI components
44
+
### Exercise 2: Implementing input components
45
+
---
36
46
37
-
**Goal**: Implement basic UI component objects to use as building blocks for page layouts.
47
+
**Goal**: Implement basic input components as Python objects, to be used as building blocks for interactive dashboards.
38
48
39
49
**Tasks**:
40
50
- Review the implementations of the `Page`, `Header` and `Text` classes in `exercise2/nanodash/components.py`
41
-
- Implement the `__init__()` and `html()`methods of the `TextInput` class
42
-
- Implement the `__init__()` and `html()`methods of the `Dropdown` class
51
+
- Implement the `html()`method of the `TextInput` class
52
+
- Implement the `html()`method of the `Dropdown` class
43
53
44
54
**Files to modify**:
45
55
-`exercise2/nanodash/components.py`
46
56
47
57
**Command to run tests**
48
58
`python -m pytest exercise2/`
49
59
50
-
### Exercise 3: Implement Graph component
60
+
### Exercise 3: Implementing the Graph component
61
+
---
51
62
52
63
**Goal**: Implement the Graph component, which uses Plotly.js to display Plotly figures in the browser.
53
64
54
65
**Tasks**:
55
-
- Implement the the `__init__()` and `html()`methods of the `Graph` class in `exercise3/nanodash/components.py`
66
+
- Implement the `html()`method of the `Graph` class in `exercise3/nanodash/components.py`
56
67
57
68
**Files to modify**:
58
69
-`exercise3/nanodash/components.py`
59
70
60
71
**Command to run tests**
61
72
`python -m pytest exercise3/`
62
73
63
-
### Exercise 4: Browser to Server Communication — Gathering the page state
74
+
### Exercise 4: Gathering the page state when an input changes
75
+
---
64
76
65
77
**Goal**: Implement the Javascript logic to capture the state of all components on the page, and bundle it into a JSON request to send to the Flask server.
66
78
67
79
Don't worry — we've provided some useful helper functions inside the Javascript file; all you need to do is put them together in the right way.
68
80
69
81
**Tasks**:
70
-
- Implement the `getState()` function in `exercise4/nanodash/static/index.js`.
82
+
- Implement the `getState()`Javascript function in `exercise4/nanodash/static/index.js`.
71
83
72
84
**Files to modify**:
73
85
-`exercise4/static/index.js`
@@ -76,12 +88,13 @@ Don't worry — we've provided some useful helper functions inside the Javascrip
76
88
`python -m pytest exercise4/`
77
89
78
90
### Exercise 5: Running callbacks
91
+
---
79
92
80
93
**Goal**: Implement the Python logic which receives the page state from the frontend, runs the necessary callbacks, and sends the results back to the frontend. Also implement the logic which allows a user to add a callback to their app.
81
94
82
95
**Tasks**:
83
-
- Implement the `handle_change()` function in `exercise5/nanodash/nanodash.py`
84
-
- Implement the `add_callback()` function in `exercise5/nanodash/nanodash.py`
96
+
- Implement the `handle_change()`Python function in `exercise5/nanodash/nanodash.py`
97
+
- Implement the `add_callback()`Python function in `exercise5/nanodash/nanodash.py`
85
98
86
99
**Files to modify**:
87
100
-`exercise5/nanodash/nanodash.py`
@@ -90,19 +103,21 @@ Don't worry — we've provided some useful helper functions inside the Javascrip
90
103
`python -m pytest exercise5/`
91
104
92
105
### Exercise 6: Updating the page with callback results
106
+
---
93
107
94
108
**Goal**: Implement the Javascript logic to update the page's UI components based on the callback results received from the server.
95
109
96
110
**Tasks**:
97
-
- Implement the `updateValues()` function in `exercise6/nanodash/static/index.js`
111
+
- Implement the `updateValues()`Javascript function in `exercise6/nanodash/static/index.js`
98
112
99
113
**Files to modify**:
100
114
-`exercise6/nanodash/static/index.js`
101
115
102
116
**Command to run tests**
103
117
`python -m pytest exercise6/`
104
118
105
-
### Exercise 7: Write your own NanoDash Application
119
+
### Exercise 7: Writing your own NanoDash application
120
+
---
106
121
107
122
**Goal**: Use the NanoDash framework to write your own interactive dashboard. You can modify the framework or add new components if you like.
0 commit comments