diff --git a/example/example.py b/example/example.py index 83a91fc..72ab18a 100644 --- a/example/example.py +++ b/example/example.py @@ -14,6 +14,7 @@ app.config['DEBUG_TB_INTERCEPT_REDIRECTS'] = True # 'flask_debugtoolbar.panels.logger.LoggingPanel', # 'flask_debugtoolbar.panels.timer.TimerDebugPanel', #) +#app.config['DEBUG_TB_HOSTS'] = ('127.0.0.1', '::1' ) app.config['SECRET_KEY'] = 'asd' app.config['DEBUG'] = True app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' diff --git a/flask_debugtoolbar/__init__.py b/flask_debugtoolbar/__init__.py index 75787fb..a338205 100644 --- a/flask_debugtoolbar/__init__.py +++ b/flask_debugtoolbar/__init__.py @@ -34,6 +34,7 @@ class DebugToolbarExtension(object): def __init__(self, app): self.app = app self.debug_toolbars = {} + self.hosts = () if not app.debug: return @@ -45,6 +46,8 @@ class DebugToolbarExtension(object): DebugToolbar.load_panels(app) + self.hosts = app.config.get('DEBUG_TB_HOSTS', ()) + self.app.before_request(self.process_request) self.app.after_request(self.process_response) @@ -90,6 +93,10 @@ class DebugToolbarExtension(object): """Return a boolean to indicate if we need to show the toolbar.""" if request.path.startswith('/_debug_toolbar/'): return False + + if len(self.hosts) and not request.remote_addr in self.hosts: + return False + return True def send_static_file(self, filename):