I\'m using code from this and that answer to send a base64 encoded image to a python FastAPI backend. The client side looks like this:
function toDataURL(src,