Skip to content

techvalidate/portrait

Repository files navigation

portrait

Portrait is a web service which converts a website into a image. The actual hard work is handled by Google’s Puppeteer. Portrait is primarily designed to be used as a service, but does have a minimal admin interface.

Dependencies

You’ll need to be able to run Puppeteer via Node.js. You’ll also need to be able to run a Rails stack. Portrait is built on Ruby 2.5.3 and Rails 5.2

Installation

The provided setup script should take care of all the necessities: installing dependencies, setting up a database, and creating a temporary admin user.

$ ./bin/setup

Once that completes successfully, spin up a rails server

$ rails server

And visit localhost:3000

How it works

Send a POST request like below. Use basic http authorization and provide a parameter named site[url]. You can test it with curl:

curl -X POST -d "site[url]=https://google.com" -H "Accept: application/json" http://admin:admin@localhost:3000/sites

On a valid url, you’ll get a json response like this:

{
  "site": {
    "id": 1,
    "status": "succeeded",
    "image": {
      "url": ".../1.png"
    }
  }
}

Author