debugtoolbar for aiohttp

aiohttp, asyncio
pip install aiohttp-debugtoolbar==0.6.1



|Build status| PyPI Chat on Gitter

aiohttp_debugtoolbar provides a debug toolbar for your aiohttp web application. Library is port of pyramid_debugtoolbar and still in early development stages. Basic functionality has been ported:

  • basic panels
  • intercept redirects
  • intercept and pretty print exception
  • interactive python console
  • show source code

Ported Panels

HeaderDebugPanel, PerformanceDebugPanel, TracebackPanel, SettingsDebugPanel, MiddlewaresDebugPanel, VersionDebugPanel, RoutesDebugPanel, RequestVarsDebugPanel, LoggingPanel

Help Needed

Are you coder looking for a project to contribute to python/asyncio libraries? This is the project for you!

Install and Configuration

$ pip install aiohttp_debugtoolbar

In order to plug in aiohttp_debugtoolbar, call aiohttp_debugtoolbar.setup on your app.

import aiohttp_debugtoolbar
app = web.Application(loop=loop)

Full Example

import asyncio
import jinja2
import aiohttp_debugtoolbar
import aiohttp_jinja2

from aiohttp import web

async def basic_handler(request):
    return {'title': 'example aiohttp_debugtoolbar!',
            'text': 'Hello aiohttp_debugtoolbar!',

async def exception_handler(request):
    raise NotImplementedError

async def init(loop):
    # add aiohttp_debugtoolbar middleware to you application
    app = web.Application(loop=loop)
    # install aiohttp_debugtoolbar

    template = """
            <title>{{ title }}</title>
            <h1>{{ text }}</h1>
              <a href="{{ app.router['exc_example'].url() }}">
              Exception example</a>
    # install jinja2 templates
    loader = jinja2.DictLoader({'index.html': template})
    aiohttp_jinja2.setup(app, loader=loader)

    # init routes for index page, and page with error
    app.router.add_route('GET', '/', basic_handler, name='index')
    app.router.add_route('GET', '/exc', exception_handler,
    return app

loop = asyncio.get_event_loop()
app = loop.run_until_complete(init(loop))
web.run_app(app, host='', port=9000)


aiohttp_debugtoolbar.setup(app, hosts=['', ])

Supported options

  • enabled: The debugtoolbar is disabled if False. By default is set to True.
  • intercept_redirects: If True, intercept redirect and display an intermediate page with a link to the redirect page. By default is set to True.
  • hosts: The list of allow hosts. By default is set to ['', '::1'].
  • exclude_prefixes: The list of forbidden hosts. By default is set to [].
  • check_host: If False, disable the host check and display debugtoolbar for any host. By default is set to True.
  • max_request_history: The max value for storing requests. By default is set to 100.
  • max_visible_requests: The max value of display requests. By default is set to 10.
  • path_prefix: The prefix of path to debugtoolbar. By default is set to '/_debugtoolbar'.


I've borrowed a lot of code from following projects. I highly recommend to check them out:

Play With Demo