GithubHelp home page GithubHelp logo

hyhlinux / aiohttp-debugtoolbar Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aio-libs/aiohttp-debugtoolbar

0.0 2.0 0.0 865 KB

aiohttp_debugtoolbar is library for debugtoolbar support for aiohttp

License: Apache License 2.0

Makefile 0.19% Python 19.12% CSS 3.14% JavaScript 77.41% HTML 0.13%

aiohttp-debugtoolbar's Introduction

aiohttp-debugtoolbar

|Build status|

image

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

image

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)

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

aiohttp-debugtoolbar's People

Contributors

alefteris avatar asvetlov avatar doubledare704 avatar himikof avatar iamraa avatar jettify avatar kammala avatar massimiliano-della-rovere avatar mihnatenko avatar mynameisfiber avatar nickolai-dr avatar pawlyk avatar pyup-bot avatar samuelcolvin avatar sloria avatar sseg avatar uralbash avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.