Is this how I suppose to use Playwright with Litestar? #4249
Unanswered
hasansezertasan
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone! 👋✨ Hope you’re all having an amazing day! 😄
I’m currently building a microservice that generates images from HTML, and after some research, Playwright looks like the perfect tool for the job! 🚀🖼️
Since this service will be running in the cloud and response time is super important, I decided to hook Playwright into the application lifecycle using lifespan events in Litestar, so the browser is always up and ready to go. ⏱️🌐
I put together a minimal reproducible example (MRE) to share with you all and would love to get your thoughts and feedback! Here it is:
Since I’ll be rendering my own HTML content (not fetching from external URLs), the request lifespan should be super short and the response almost instant. ⚡️
I chose to use lifespans because I’ve had some experience with Starlette Lifespan State, and after checking out the Litestar docs, it seemed like a good fit here too.
Has anyone tried something similar, or have any tips, tricks, or best practices to share? Would really appreciate your insights! 🙏💡
Thanks so much in advance! Looking forward to hearing your ideas! 😊🙌
Beta Was this translation helpful? Give feedback.
All reactions