I would really like to know why base64 encoding and decoding works instead of app.get_asset_rul()
1 Like
me too. but thx dayxx369
It works, thx!
Came here looking to reference images in a parent/ different folders like so
html.Img(src="../../docs/images/some_img.png"),
hmm looks like there are other options for asset locations. i feel like that is low-level instantiation stuff that i wouldn’t trust to stick/ might be hardcoded in some places
>>> app.config
{
'assets_folder': '/Users/me/Desktop/AIQC/aiqc/lab/assets',
'assets_url_path': 'assets',
'assets_ignore': '',
'assets_external_path': '',
The base64 encoding example didn’t function because it was still in a binary object, and should be decoded to a utf8 or ascii string.
The data URL for SVG image requires a different mimetype (image/svg+xml).
But in general I would recommend the app.get_asset_url method, since it allows the browser to cache the image, and makes the HTML smaller.
I’ve put everything together in a PyCafe example showing they all three method working:
2 Likes