Skip to main content

UNKNOWN

Project description

aiohttp_route_decorator

The library provides @route decorator for aiohttp.web.

The imaginary @app.route decorator is discouraged for multiple reasons; this one tries to solve part of those problems (the app doesn’t need to be global at the very least).

Usage

Create a route object in each of your handler modules, and decorate the handlers:

from aiohttp_route_decorator import RouteCollector

route = RouteCollector()


@route('GET', '/', name='index')
async def handler(request):
        return web.Response(body=b'OK')

When you init the application, push the collected routes into app.router:

from aiohttp import web

from myapp import handlers


def run():
        app = web.Application()
        handlers.route.add_to_router(app.router)
        web.run_app(app)

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_route_decorator-0.0.1.tar.gz (1.8 kB view hashes)

Uploaded Source

Supported by

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