There are two approaches to rendering a Base64-encoded image directly from the database. One technique is to create a standalone Python script that accepts a product key as a parameter, looks up the product, Base64 decodes the data, and outputs an appropriate Content-Type header for that image, along with the actual binary image data.
The second approach is to output the image using the following format:
<img src="data:image/xxx;base64,yyy" />
Here, xxx is the image type (for example, image/png) and yyy is the actual Base64 string. Although this approach puts the burden on the browser to perform the decoding, it minimizes the impact on the database and web server. For the purposes of illustration, we will use the second approach.
Accordingly, we return to our HTML responder class and add a method that produces the appropriate HTML image tag:
# web.responder.html.Html
mimeTypes = dict({'png':'image/png',&apos...