Playwright integration for Litestar.
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 π.
- π 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
uv add litestar-playwrightCheck out the Quick Start example to see how to use the plugin.
Check out the Multiple Playwright Plugins example to see how to use multiple plugins in a single application.
If you have any questions or need help, feel free to open an issue on the GitHub repository.
Any contributions are welcome! Please follow the Contributing Guidelines to contribute to this project.
This project is maintained by Hasan Sezer TaΕan, It's me π
Clone the repository and cd into the project directory:
git clone https://github.com/hasansezertasan/litestar-playwright
cd litestar-playwrightThe 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 the dependencies:
uv sync
uv run playwright installRun the style checks:
uv run --locked tox run -e styleRun the CI pipeline:
uv run --locked tox runRun the simple example:
uv run python examples/simple.pyRun the multiple plugins example:
uv run python examples/multiple_plugins.pylitestar-playwright is distributed under the terms of the MIT license.
For a detailed list of changes, please refer to the CHANGELOG.