https://github.com/frappe/preview_generator
Generates preview image for HTML
https://github.com/frappe/preview_generator
Last synced: 4 days ago
JSON representation
Generates preview image for HTML
- Host: GitHub
- URL: https://github.com/frappe/preview_generator
- Owner: frappe
- License: mit
- Created: 2024-04-05T09:27:23.000Z (about 1 year ago)
- Default Branch: develop
- Last Pushed: 2025-03-12T12:03:55.000Z (3 months ago)
- Last Synced: 2025-04-14T14:58:58.098Z (2 months ago)
- Language: Python
- Size: 22.5 KB
- Stars: 17
- Watchers: 9
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
# Preview Generator
Generate a rendered HTML preview image from a website URL or HTML snippet.
## Installation
Install this app using the [bench](https://github.com/frappe/bench) CLI:
```bash
cd $PATH_TO_YOUR_BENCH
bench get-app $URL_OF_THIS_REPO --branch develop
bench install-app preview_generator
```You might need to install Playwright for the app to work. You can do this by running the following commands:
```
source $PATH_TO_YOUR_BENCH/env/bin/activate
playwright install
```## Usage
### Generate Preview of a URL
Make a POST request to `/api/method/preview_generator.api.generate_preview_from_url` with the following parameters:
```js
{
"url": "https://www.example.com", // URL of the webpage for which you want to genetate a preview
"wait_for": 5000, // In milliseconds, optional, default is 0
"headers": {}, // Optional, headers to be provided when visiting the URL
"format": "webp" // Optional, default is "jpg"
}
```
**Note:** The URL passed should be publicly accessible.### Generate Preview of HTML Content
Make a POST request to `/api/method/preview_generator.api.generate_preview` with the following parameters:
```js
{
"html": "Hello World
", // Your HTML content
"format": "webp" // Optional, default is "jpg"
}
```This will return a preview image.
## License
MIT License