Skip to content

Commit 437dd33

Browse files
committed
Move dev_tools activation to method.
1 parent c8571cb commit 437dd33

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

dash/dash.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,14 @@ def serve_component_suites(self, package_name, path_in_package_dist):
425425
'js': 'application/JavaScript',
426426
'css': 'text/css'
427427
})[path_in_package_dist.split('.')[-1]]
428+
429+
headers = {
430+
# 'Cache-Control': 'public, max-age=3600'
431+
}
428432
return Response(
429433
pkgutil.get_data(package_name, path_in_package_dist),
430-
mimetype=mimetype
434+
mimetype=mimetype,
435+
headers=headers
431436
)
432437

433438
def index(self, *args, **kwargs): # pylint: disable=unused-argument
@@ -953,11 +958,29 @@ def get_asset_url(self, path):
953958
self.config.routes_pathname_prefix,
954959
path)
955960

961+
def activate_dev_tools(self,
962+
dev_tools=True,
963+
dev_tools_bundles=True):
964+
"""
965+
Activate the dev tools, called by `run_server`. If your application is
966+
served by wsgi and you want to activate the dev tools, you can call
967+
this method out of `__main__`.
968+
969+
:param dev_tools: If false no tools will be activated.
970+
:type dev_tools: bool
971+
:param dev_tools_bundles: Serve the dev bundles of component libs.
972+
:type dev_tools_bundles: bool
973+
:return:
974+
"""
975+
if not dev_tools:
976+
return
977+
self._serve_dev_bundle = dev_tools_bundles
978+
956979
def run_server(self,
957980
port=8050,
958981
debug=False,
959982
dev_tools=True,
960-
dev_tools_bundles=False,
983+
dev_tools_bundles=True,
961984
**flask_run_options):
962985
"""
963986
Start the flask server in local mode, you should not run this on a
@@ -975,6 +998,6 @@ def run_server(self,
975998
:param flask_run_options: Given to `Flask.run`
976999
:return:
9771000
"""
978-
self._serve_dev_bundle = dev_tools_bundles or dev_tools
1001+
self.activate_dev_tools(dev_tools, dev_tools_bundles)
9791002
self.server.run(port=port, debug=dev_tools or debug,
9801003
**flask_run_options)

0 commit comments

Comments
 (0)