Code
HTTP
import puppeteer from "npm:puppeteer-core";
export default async () => {
const browserlessApi = Deno.env.get("BROWSERLESS_API_KEY");
const browser = await puppeteer.connect({
browserWSEndpoint: `wss://chrome.browserless.io?token=${browserlessApi}`,
});
const page = await browser.newPage();
const html = "<h1>hi</h1>";
await page.setContent(html);
const screenshot = await page.pdf();
await page.close();
await browser.close();
return new Response(screenshot, {
headers: {
"Content-Type": "application/pdf",
},
});
};
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
tmcw-untitled_redearthworm.web.val.run
Updated: February 5, 2024