Skip to main content

debugtoolbar for aiohttp

Project description

|Build status| https://codecov.io/gh/aio-libs/aiohttp-debugtoolbar/branch/master/graph/badge.svg 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

https://raw.githubusercontent.com/aio-libs/aiohttp_debugtoolbar/master/demo/aiohttp_debugtoolba_sceenshot.png

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)
aiohttp_debugtoolbar.setup(app)

Full Example

import asyncio
import jinja2
import aiohttp_debugtoolbar
import aiohttp_jinja2

from aiohttp import web


@aiohttp_jinja2.template('index.html')
async def basic_handler(request):
    return {'title': 'example aiohttp_debugtoolbar!',
            'text': 'Hello aiohttp_debugtoolbar!',
            'app': request.app}


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
    aiohttp_debugtoolbar.setup(app)

    template = """
    <html>
        <head>
            <title>{{ title }}</title>
        </head>
        <body>
            <h1>{{ text }}</h1>
            <p>
              <a href="{{ app.router['exc_example'].url() }}">
              Exception example</a>
            </p>
        </body>
    </html>
    """
    # 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,
                         name='exc_example')
    return app


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

Settings

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

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 [‘127.0.0.1’, ‘::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’.

Thanks!

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

Play With Demo

https://github.com/aio-libs/aiohttp_debugtoolbar/tree/master/demo

Requirements

CHANGES

0.6.0 (2020-01-25)

  • Fix ClassBasedView support #207

  • Drop aiohttp<3.3 support

  • Drop Python 3.4 support

  • Drop yeild from and @asyncio.coroutine support

0.5.0 (2018-02-14)

  • Add safe filter to render_content #195

  • Adopt to aiohtp 3.0

0.4.1 (2017-08-30)

  • Fixed issue with redirects without location header #174

0.4.0 (2017-05-04)

  • Added asyncio trove classifier

  • Addes support for aiohttp>=2.0.7

0.3.0 (2016-11-18)

  • Fixed middleware route finding when using sub-apps #65

  • Add examples for extra panels: pgsql & redis monitor #59

0.2.0 (2016-11-08)

  • Refactor test suite

0.1.4 (2016-11-07)

  • Rename to aiohttp-debugtoolbar

  • Fix imcompatibility with aiohttp==1.1

0.1.3 (2016-10-27)

  • Fix a link to request info page, sort request information alphabetically #52

0.1.2 (2016-09-27)

  • Fixed empty functions names in performance panel #43 (Thanks @kammala!)

  • Fixed flashing message during page rendering issue #46

0.1.1 (2016-02-21)

  • Fixed a demo

  • Added syntax highlight in traceback view, switched highlighter from highlight.js to prism.js #31

0.1.0 (2016-02-13)

  • Fixed python 3.5 support (Thanks @stormandco!)

  • Added view source button in RoutesDebugPanel (Thanks @stormandco!)

  • Dropped support for Python 3.3 (Thanks @sloria!)

  • Add middleware in setup method (Thanks @sloria!)

  • Fixed bug with interactive console

  • Fixed support for aiohttp>=0.21.1

0.0.5 (2015-09-13)

  • Fixed IPv6 socket family error (Thanks @stormandco!)

0.0.4 (2015-09-05)

  • Fixed support for aiohttp>=0.17. (Thanks @himikof!)

0.0.3 (2015-07-03)

  • Switched template engine from mako to jinja2. (Thanks @iho!)

  • Added custom yield from to track context switches inside coroutine.

  • Implemented panel for collecting request log messages.

  • Disable toolbar code injecting for non web.Response answers (StreamResponse or WebSocketResponse for example) #12

0.0.2 (2015-05-26)

  • Redesign UI look-and-feel

  • Rename toolbar_middleware_factory to just middleware.

0.0.1 (2015-05-18)

  • Initial release.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiohttp-debugtoolbar-0.6.0.tar.gz (444.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiohttp_debugtoolbar-0.6.0-py3-none-any.whl (466.0 kB view details)

Uploaded Python 3

File details

Details for the file aiohttp-debugtoolbar-0.6.0.tar.gz.

File metadata

  • Download URL: aiohttp-debugtoolbar-0.6.0.tar.gz
  • Upload date:
  • Size: 444.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for aiohttp-debugtoolbar-0.6.0.tar.gz
Algorithm Hash digest
SHA256 ec231661133b40136608d39dfb688e7ea0c3d47b6ae6dee52d5bf24ceb9e4d45
MD5 496734057cb413d7a49a52a817802dbb
BLAKE2b-256 3fdd5121417dfbeb4661673afa5c8708f1539889d0e54b1509a6fdf66705efc5

See more details on using hashes here.

File details

Details for the file aiohttp_debugtoolbar-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: aiohttp_debugtoolbar-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 466.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.7.1

File hashes

Hashes for aiohttp_debugtoolbar-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e94c3fff7a49eb33d32c7b5b2e268fbd97c5bfca40128965f839c4815359c05a
MD5 46efa434bf8467de7c13217b977f873a
BLAKE2b-256 b7ac5508f003928d95d8ae5a2e37e4f6228d48f5e0241cd3cc086e751683a3f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page