-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
36 lines (33 loc) · 950 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const puppeteer = require("puppeteer");
exports.handler = async (event, ctx, callback) => {
const browser = await puppeteer.launch({
ignoreHTTPSErrors: true,
args: [
"--disable-dev-shm-usage",
"--no-zygote",
"--use-gl=swiftshader",
"--enable-webgl",
"--hide-scrollbars",
"--mute-audio",
"--no-sandbox",
"--single-process",
"--disable-breakpad",
"--ignore-gpu-blacklist",
"--headless"
],
executablePath: "./headless_chromium/headless_shell"
});
const page = await browser.newPage();
await page.setViewport({ width: 800, height: 600 });
await page.goto("https://get.webgl.org/");
const screenshot = await page.screenshot();
const body = screenshot.toString("base64");
const response = {
statusCode: 200,
headers: { "Content-Type": "image/png" },
body,
isBase64Encoded: true
};
await browser.close();
callback(null, response);
};