received raw code string:
a%3Dlambda+x%3A+x%2A2%3B+b=1/a(2)%0Ab-3;c=4;d=5;e=8;a(2)-b-c-d
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