Guest User

Untitled

a guest
Oct 24th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. FROM node:8.7.0-slim
  2.  
  3. RUN apt-get update && \
  4. apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
  5. libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
  6. libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
  7. libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
  8. ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
  9.  
  10. RUN npm i puppeteer micro qs
  11.  
  12. RUN echo "\
  13. const { parse } = require('qs')\n\
  14. const { send } = require('micro')\n\
  15. const puppeteer = require('puppeteer')\n\
  16.  
  17. module.exports = async (req, res) => {\n\
  18. async function timings (url) {\n\
  19. const browser = await puppeteer.launch({\n\
  20. // ommmmm\n\
  21. args: ['--disable-setuid-sandbox', '--no-sandbox']\n\
  22. })\n\
  23. const page = await browser.newPage()\n\
  24. await page.goto(url)\n\
  25. const t = await page.evaluate(() => {\n\
  26. return window.performance.timing\n\
  27. })\n\
  28. await browser.close()\n\
  29. return t\n\
  30. }\n\
  31.  
  32. let url = req.url\n\
  33. const index = url.indexOf('?')\n\
  34.  
  35. if (index !== -1) {\n\
  36. url = url.substr(index + 1)\n\
  37. }\n\
  38.  
  39. const query = parse(url)\n\
  40. const t = await timings(query.url)\n\
  41. return t\n\
  42. }\n\
  43. " > index.js
  44.  
  45. CMD ["node_modules/.bin/micro", "index.js"]
Add Comment
Please, Sign In to add comment