Hi Jaako,
> how can generate the STL file bytes from the cadquery Workplane without writing them to a file?
Export with exportType STL uses OCP.StlAPI.StlAPI_Writer. The StlAPI_Writer expects a string argument for filename so I don't see an easy way to avoid this without writing a temp file.
The AMF exportType also currently writes to file but with some minor Python code changes to the AmfWriter you could support writing to IO stream.
Regarding display in the browser, I would suggest to take a look at jupyter_tools.py. Disclaimer - I have not build such an app. My advice is based on using cadquery with jupyter lab. As a jupyter lab user I know that cadquery natively supports display in the browser. I think the HTML docs use the same (VTK) method for display in the browser as well (see cq_directive.py).
Lorenz