url2_image package

Submodules

url2_image.app module

GET /getImage

Main API endpoint. This takes in an URL and returns an image.

Args:

url (str): The URL of the target website to be downloaded.

width (int): Width of the target image (default=1920)

height (int): Height of the target image (default=1080)

format (str): The format of the target image. Either png or jpg (default=png)

quality (int): JPEG Quality from 0 to 100 (default=60)

Returns:
A bytestream containing the downloaded website as image
GET /version

API endpoint to retrieve version information of the service.

Example:

The Api endpoint can be queried as follows:

$ curl "localhost:5000/version"
$ curl "localhost:5000/version?format=json"
Args:
format (str): (Optional) when format=json a json object is returned
Returns:
Version information of the service either as plaintext or json. Information contains version number, git hash (one commit behind) and git branch.
POST /login

Login the user using flask_jwt_extented. Accepts json as input and returns an access token. The configuration can be set via environment variables:

  • JWT_SECRET_KEY: The secret key for JWT
  • JWT_USER: The username of the JWT login. Default: user
  • JWT_PASSWORD: The password for the JWT login. Default: url2image
  • USE_LOGIN: Enables/Disables the requirement for login via JWT. Default: True
  • JWT_ACCESS_TOKEN_EXPIRES: The expiration time (in seconds) of False for no expiration of the JWT. Default: False

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"

Args:

username: The username to login

password: The users password

Returns:
The generated access token.
GET /

Return “Hello World” as a default for the “/” route

Main file for the url2_image app

Module contents