Skip to content

Commit 8503dfa

Browse files
committed
allow specifying extra files and/or directories to watch for hot reloading
1 parent efc42b4 commit 8503dfa

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

dash/dash.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ class Dash(object):
232232
and redo buttons for stepping through the history of the app state.
233233
:type show_undo_redo: boolean
234234
235+
:param extra_hot_reload_paths: A list of paths to watch for changes, in
236+
addition to assets and known Python and JS code, if hot reloading is
237+
enabled.
238+
:type extra_hot_reload_paths: list of strings
239+
235240
:param plugins: Extend Dash functionality by passing a list of objects
236241
with a ``plug`` method, taking a single argument: this app, which will
237242
be called after the Flask server is attached.
@@ -269,6 +274,7 @@ def __init__(
269274
suppress_callback_exceptions=None,
270275
prevent_initial_callbacks=False,
271276
show_undo_redo=False,
277+
extra_hot_reload_paths=None,
272278
plugins=None,
273279
title="Dash",
274280
update_title="Updating...",
@@ -329,6 +335,7 @@ def __init__(
329335
),
330336
prevent_initial_callbacks=prevent_initial_callbacks,
331337
show_undo_redo=show_undo_redo,
338+
extra_hot_reload_paths=extra_hot_reload_paths or [],
332339
title=title,
333340
update_title=update_title,
334341
)
@@ -1730,4 +1737,14 @@ def verify_url_part(served_part, url_part, part_name):
17301737

17311738
self.logger.info("Dash is running on %s://%s%s%s\n", *display_url)
17321739

1740+
if self.config.extra_hot_reload_paths:
1741+
extra_files = flask_run_options["extra_files"] = []
1742+
for path in self.config.extra_hot_reload_paths:
1743+
if os.path.isdir(path):
1744+
for dirpath, _, filenames in os.walk(path):
1745+
for fn in filenames:
1746+
extra_files.append(os.path.join(dirpath, fn))
1747+
elif os.path.isfile(path):
1748+
extra_files.append(path)
1749+
17331750
self.server.run(host=host, port=port, debug=debug, **flask_run_options)

0 commit comments

Comments
 (0)