Skip to content

hasansezertasan/litestar-playwright

litestar-playwright

CI PyPI - Version PyPI - Python Version License - MIT Latest Commit

Checked with mypy Linted and formatted with Ruff GitHub Tag

Downloads Downloads/Month Downloads/Week

Playwright integration for Litestar.


Table of Contents

About

litestar-playwright is a plugin for Litestar that provides Playwright integration.

✨ This project was born out of necessity when I was working on a project that required me to take screenshots πŸ“Έof given HTML content. I was using Playwright for this purpose, but I was not satisfied with my workflow. While improving the workflow, I started a discussion πŸ’¬ at the Litestar Organization. Even though the discussion had zero activity πŸ’€, it was a great opportunity to discover some of the internal mechanisms of Litestar. After over-engineering the workflow πŸ€“, I decided to create a plugin for Litestar that would provide seamless Playwright integration. I learned a lot about how to use Playwright with Litestar on the way πŸš€.

Features

  • 🎭 Browser Management: Manage Playwright browser instances
  • πŸ”§ Dependency Injection: Automatic injection of browser instances into route handlers
  • ⚑ Async Support: Full async/await support for all operations

Installation

uv add litestar-playwright

Usage

Simple Example

Check out the Quick Start example to see how to use the plugin.

Multiple Playwright Plugins Example

Check out the Multiple Playwright Plugins example to see how to use multiple plugins in a single application.

Support βœ‰οΈ

If you have any questions or need help, feel free to open an issue on the GitHub repository.

Contributing :octocat:

Any contributions are welcome! Please follow the Contributing Guidelines to contribute to this project.

Author πŸ‘‘

This project is maintained by Hasan Sezer Taşan, It's me πŸ‘‹

Tasks

Clone the repository and cd into the project directory:

git clone https://github.com/hasansezertasan/litestar-playwright
cd litestar-playwright

The commands below can also be executed using the xc task runner, which combines the usage instructions with the actual commands. Simply run xc, it will pop up an interactive menu with all available tasks.

install

Install the dependencies:

uv sync
uv run playwright install

style

Run the style checks:

uv run --locked tox run -e style

ci

Run the CI pipeline:

uv run --locked tox run

run-simple

Run the simple example:

uv run python examples/simple.py

run-multiple-plugins

Run the multiple plugins example:

uv run python examples/multiple_plugins.py

License

litestar-playwright is distributed under the terms of the MIT license.

Changelog πŸ“

For a detailed list of changes, please refer to the CHANGELOG.