跳转到主要内容

buvar的aiohttp插件

项目描述

解决启动aiohttp服务器的一些模板代码。

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"])

项目详情


下载文件

为您的平台下载文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

buvar_aiohttp-0.4.5.tar.gz (10.6 kB 查看散列)

上传时间:

构建分布

buvar_aiohttp-0.4.5-py3-none-any.whl (10.6 kB 查看散列)

上传时间: Python 3

由以下支持