Download deploy/scripts/shot.js from eduzrh/helloworld: direct link, hf CLI and curl.
- Browser
- Download file 2.02 kB
-
https://huggingface.co/datasets/eduzrh/helloworld/resolve/main/deploy/scripts/shot.js
- Command line
-
hf download hf://datasets/eduzrh/helloworld/deploy/scripts/shot.js
-
curl -L -o shot.js https://huggingface.co/datasets/eduzrh/helloworld/resolve/main/deploy/scripts/shot.js
2.02 kB
| const { chromium } = require('playwright-core'); | |
| const fs = require('fs'); | |
| const OUT = '/data/shots'; | |
| const PAGES = [ | |
| { name: 'shadowbroker', url: 'http://127.0.0.1/', wait: 25000 }, | |
| { name: 'cdhe', url: 'http://127.0.0.1/cdhe/', wait: 8000 }, | |
| { name: 'cdhe_single', url: 'http://127.0.0.1/cdhe/cdhe-monitor.html', wait: 8000 }, | |
| { name: 'worldmonitor', url: 'http://127.0.0.1/wm/', wait: 20000 }, | |
| ]; | |
| (async () => { | |
| fs.mkdirSync(OUT, { recursive: true }); | |
| const browser = await chromium.launch({ | |
| executablePath: '/data/tools/chrome-headless-shell-linux64/chrome-headless-shell', | |
| args: ['--no-sandbox', '--disable-dev-shm-usage', '--use-gl=swiftshader', | |
| '--enable-unsafe-swiftshader', '--disable-gpu-sandbox'], | |
| }); | |
| const report = []; | |
| for (const p of PAGES) { | |
| const ctx = await browser.newContext({ viewport: { width: 1600, height: 1000 }, | |
| deviceScaleFactor: 1, ignoreHTTPSErrors: true }); | |
| const page = await ctx.newPage(); | |
| const errs = []; | |
| page.on('console', m => { if (m.type() === 'error') errs.push(m.text().slice(0, 200)); }); | |
| page.on('pageerror', e => errs.push('PAGEERROR ' + String(e).slice(0, 200))); | |
| let status = 0; | |
| try { | |
| const resp = await page.goto(p.url, { waitUntil: 'domcontentloaded', timeout: 60000 }); | |
| status = resp ? resp.status() : 0; | |
| await page.waitForTimeout(p.wait); | |
| const title = await page.title(); | |
| await page.screenshot({ path: `${OUT}/${p.name}.png`, fullPage: false }); | |
| const txt = (await page.evaluate(() => document.body.innerText)).replace(/\s+/g, ' ').slice(0, 300); | |
| report.push({ name: p.name, status, title, errors: errs.length, sample: txt, | |
| err_samples: errs.slice(0, 3) }); | |
| } catch (e) { | |
| report.push({ name: p.name, status, error: String(e).slice(0, 300) }); | |
| } | |
| await ctx.close(); | |
| } | |
| await browser.close(); | |
| fs.writeFileSync(`${OUT}/report.json`, JSON.stringify(report, null, 1)); | |
| console.log(JSON.stringify(report, null, 1)); | |
| })(); | |