Skip to content

A microservice that turns an URL into an image

License

Notifications You must be signed in to change notification settings

ImFlow/URL2Image

Repository files navigation

Build Status Coverage Status License: MIT Documentation Status

URL2Image

A microservice that turns an URL into an image aka it takes a screenshot of the website.

What it is

URL2Image provides an API, which accepts a URL and returns a rendered image of the URL.

Installation

Either clone the repo and run it yourself:

git clone https://github.com/ImFlow/URL2Image.git

and then run it via:

docker build -t url2image .
docker run -d -p 5000:5000 url2image

or use the prebuild docker image:

docker pull imflow/url2image
docker run -d -p 5000:5000 url2image

there is also a docker-compose.yml file included so the service can be run using:

docker-compose up

How To Use

To download an url as a png file call the /getImage endpoint.

curl "localhost:5000/getImage?url=google.de" -o test.png

Supported options are url to specify the url of the target. This is required. width and height are optional parameters specifiing the image dimensions.

curl "localhost:5000/getImage?url=google.de&width=400&height=400" -o test.png

A basic login can be achieved via:

curl -H "Content-Type: application/json" -X POST -d '{"username":"user", "password":"url2image" }' "http://localhost:5000/login"
{
    "access_token": "TOKEN"
}

The authorization is then done in the header::

curl -H "Authorization: Bearer TOKEN" "http://localhost:5000/getImage?url=google.de"

Documentation

More documentation can be found here

Configuration

The service can be configured using environtment variables:

Variable  Description  Default Value
JWT_SECRET_KEY Secret key for the JWT access tokens Random String
JWT_USER The username for the JWT authentification "user"
JWT_PASSWORD The password for the JWT authentification "url2image"
FLASK_DEBUG Run in debug mode. Currently only disables the DDos protection not set
USE_LOGIN Enables the authorization requirement for the service  True
JWT_ACCESS_TOKEN_EXPIRES Expiration time of the JWT in seconds or False for no expiration  False

TODO

✅ Design API

✅ Provide API endpoints

✅ DDos protection

✅ JWT authentification

✅ Username/Password authentification

✅ Configs

✅ Image format selection (jpg/png)

  • Add a standalone Program