Skip to main content

aiohttp plugin for buvar

Project description

Solves some boilerplate around starting an aiohttp server.

import aiohttp.web
from buvar import context, di, fork, plugin

from buvar_aiohttp import AioHttpConfig


async def hello(request):
    return aiohttp.web.Response(body=b"Hello, world")


async def prepare_aiohttp(load: plugin.Loader):
    # provide config
    context.add(AioHttpConfig(host="0.0.0.0", port=5678))

    # prepare server site
    await load("buvar_aiohttp")

    # mount routes
    app = await di.nject(aiohttp.web.Application)
    app.router.add_route("GET", "/", hello)


# start a process for each available CPU and provide a shared socket to all
# children
fork.stage(prepare_aiohttp, forks=0, sockets=["tcp://:5678"])

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

buvar_aiohttp-0.4.4.tar.gz (5.0 kB view hashes)

Uploaded source

Built Distribution

buvar_aiohttp-0.4.4-py3-none-any.whl (12.7 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page