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.5.1.tar.gz (5.8 kB view details)

Uploaded Source

File details

Details for the file buvar_aiohttp-0.5.1.tar.gz.

File metadata

  • Download URL: buvar_aiohttp-0.5.1.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for buvar_aiohttp-0.5.1.tar.gz
Algorithm Hash digest
SHA256 db92374d7e6925b937a0afeaca11e6b2d4c26afabf6b2cf252a58520470bc294
MD5 ae9993b9831244f68ac86f305c98a508
BLAKE2b-256 7e84f56c5486b7eef375764166ab0ac75d8743f6046be4c1bce408423f9ff5a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for buvar_aiohttp-0.5.1.tar.gz:

Publisher: package.yaml on diefans/buvar_aiohttp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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