async def convert_body(request: Request):
    "\n    It's just _way_ easier to deal with files rather than STDIN.\n\n    Take the body of the request, write it to a temporary file, then use\n    wkhtmltopdf to convert it.\n    "
    data = (await request.body())
    if (not data):
        return Response('ERROR: No body', status_code=400)
    with TemporaryDirectory() as tmpdirname:
        outfile = os.path.join(tmpdirname, 'out.html')
        with open(outfile, 'w') as fh:
            fh.write(data.decode('utf-8'))
        bytes = (await execute_wkhtmltopdf(outfile))
    return Response(bytes, media_type='application/pdf')
It's just _way_ easier to deal with files rather than STDIN.

Take the body of the request, write it to a temporary file, then use
wkhtmltopdf to convert it.
async def convert_body(request: Request):
    "\n    It's just _way_ easier to deal with files rather than STDIN.\n\n    Take the body of the request, write it to a temporary file, then use\n    wkhtmltopdf to convert it.\n    "
    data = (await request.body())
    if (not data):
        return Response('ERROR: No body', status_code=400)
    with TemporaryDirectory() as tmpdirname:
        outfile = os.path.join(tmpdirname, 'out.html')
        with open(outfile, 'w') as fh:
            fh.write(data.decode('utf-8'))
        bytes = (await execute_wkhtmltopdf(outfile))
    return Response(bytes, media_type='application/pdf')