Пример #1
0
async def render_html(bot, payload):
    try:
        async with bot.session.post(
            f"http://{IMAGE_SERVER_HOST}:3000/html", data=payload
        ) as response:
            if response.status == 200:
                buffer = io.BytesIO(await response.read())
                return buffer
            raise exceptions.RendererError(f"{response.status} : {await response.text()}")
    except aiohttp.client_exceptions.ClientConnectorError:
        raise exceptions.RendererError("Unable to connect to the HTML Rendering server")
Пример #2
0
async def render_html(payload):
    async with aiohttp.ClientSession() as session:
        try:
            async with session.post("http://localhost:3000/html", data=payload) as response:
                buffer = io.BytesIO(await response.read())
        except aiohttp.client_exceptions.ClientConnectorError:
            raise exceptions.RendererError("Unable to connect to the HTML Rendering server")

    return buffer