received raw code string:
a%3Dlambda%20x%3A%20x*2%3B%20b%3D1%2Fa(2)%0Ab-3
Here you can see a prettified version of the code string and the result of executing it via IPython
This image has been generated on the fly using a serverless vercel python function
You can see the code that generated this image here
A simple explanation of how it works
- GET Request to /py
- Vercel serves html file to the client
- Browser: GET /api/py.png
- Vercel executes lambda function /api/py.png.ts
- GET /api/py_pretty: prettyfies the code using ptyhon-black
- GET /api/py_exec: executes the code using IPython and returns stdout
- html from template.html with mustache
- uses playwright to get a screenshot of the html
- return the image to the client
An og:image tag is set so that this also works on the fly for twitter and social media