def METHOD_NAME(url, html):
    # This needs to fetch URLs found within the page, so if
    # you're running a dev server, use app.run(processes=2)
    async def to_pdf():
        browser = await launch(
            # Handlers don't work as we're not in the main thread.
            handleSIGINT=False,
            handleSIGTERM=False,
            handleSIGHUP=False,
            # --no-sandbox is necessary as we're running as root (in docker!)
            args=["--no-sandbox"],
        )
        page = await browser.newPage()
        async def request_intercepted(request):
            app.logger.debug("Intercepted URL: %s", request.url)
            if request.url == url:
                await request.respond({"body": html})
            else:
                await request.continue_()
        page.on("request", lambda r: asyncio.ensure_future(request_intercepted(r)))
        await page.setRequestInterception(True)
        await page.goto(url)
        pdf = await page.pdf(format="A4")
        await browser.close()
        return pdf
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    pdf = loop.run_until_complete(to_pdf())
    pdffile = io.BytesIO(pdf)
    return pdffile