Esempio n. 1
0
    def setup(self, app):
        self.app = app

        if not self.enabled:
            return

        DebugToolbar.load_panels(self.config)

        self.hosts = self.config.get('DEBUG_TB_HOSTS', ())

        # Configure jinja for the internal templates and add url rules
        # for static data
        self.jinja_env = Environment(
            autoescape=True,
            extensions=['jinja2.ext.i18n', 'jinja2.ext.with_'],
            loader=PackageLoader(__name__, 'templates'))
        self.jinja_env.filters['urlencode'] = url_quote_plus
        self.jinja_env.filters['printable'] = _printable

        self.app.route(path='/_debug_toolbar/static/<filename:path>',
                       name='_debug_toolbar.static',
                       callback=self.send_static_file)