How to show local gif image?

import streamlit as st
import base64

"""### gif from url"""
st.markdown("![Alt Text](https://media.giphy.com/media/vFKqnCdLPNOKc/giphy.gif)")

"""### gif from local file"""
file_ = open("/home/rzwitch/Desktop/giphy.gif", "rb")
contents = file_.read()
data_url = base64.b64encode(contents).decode("utf-8")
file_.close()

st.markdown(
    f'<img src="data:image/gif;base64,{data_url}" alt="cat gif">',
    unsafe_allow_html=True,
)

Feature request: https://github.com/streamlit/streamlit/issues/1566

8 Likes