Skip to content

Instantly share code, notes, and snippets.

View dariushazimi's full-sized avatar

Dariush Azimi dariushazimi

View GitHub Profile
@treuille
treuille / render_svg.py
Last active May 20, 2024 21:42
Workaround: Displaying SVG images in Streamlit
import streamlit as st
import base64
import textwrap
def render_svg(svg):
"""Renders the given svg string."""
b64 = base64.b64encode(svg.encode('utf-8')).decode("utf-8")
html = r'<img src="data:image/svg+xml;base64,%s"/>' % b64
st.write(html, unsafe_allow_html=True)