Skip to content

Commit

Permalink
Move dev_tools activation to method.
Browse files Browse the repository at this point in the history
  • Loading branch information
T4rk1n committed Sep 10, 2018
1 parent c8571cb commit 72a0db7
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ def serve_component_suites(self, package_name, path_in_package_dist):
'js': 'application/JavaScript',
'css': 'text/css'
})[path_in_package_dist.split('.')[-1]]

return Response(
pkgutil.get_data(package_name, path_in_package_dist),
mimetype=mimetype
Expand Down Expand Up @@ -953,11 +954,29 @@ def get_asset_url(self, path):
self.config.routes_pathname_prefix,
path)

def activate_dev_tools(self,
dev_tools=True,
dev_tools_bundles=True):
"""
Activate the dev tools, called by `run_server`. If your application is
served by wsgi and you want to activate the dev tools, you can call
this method out of `__main__`.
:param dev_tools: If false no tools will be activated.
:type dev_tools: bool
:param dev_tools_bundles: Serve the dev bundles of component libs.
:type dev_tools_bundles: bool
:return:
"""
if not dev_tools:
return
self._serve_dev_bundle = dev_tools_bundles

def run_server(self,
port=8050,
debug=False,
dev_tools=True,
dev_tools_bundles=False,
dev_tools_bundles=True,
**flask_run_options):
"""
Start the flask server in local mode, you should not run this on a
Expand All @@ -975,6 +994,6 @@ def run_server(self,
:param flask_run_options: Given to `Flask.run`
:return:
"""
self._serve_dev_bundle = dev_tools_bundles or dev_tools
self.activate_dev_tools(dev_tools, dev_tools_bundles)
self.server.run(port=port, debug=dev_tools or debug,
**flask_run_options)

0 comments on commit 72a0db7

Please sign in to comment.