A microservice that turns an URL into an image aka it takes a screenshot of the website.
URL2Image provides an API, which accepts a URL and returns a rendered image of the URL.
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
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"
More documentation can be found here
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 |
✅ Design API
✅ Provide API endpoints
✅ DDos protection
✅ JWT authentification
✅ Username/Password authentification
✅ Configs
✅ Image format selection (jpg/png)
- Add a standalone Program