I am new to Streamlit, and am trying to build a simple app which will show a cat picture from https://cataas.com/cat on clicking a button. I have the following simple code:
def show_kitty():
st.image('https://cataas.com/cat')
st.button("Click for cats", on_click = show_kitty())
However, the app renders a picture on the first button click, and the picture does not change on subsequent clicks.
I tried doing the same with texts instead of images, this time displaying cat facts:
def get_cat_fact():
x = requests.get('https://catfact.ninja/fact')
st.text(x.text)
st.button("Click for cat facts", on_click = get_cat_fact())
and it worked - the text changes on every button click.
Does anyone know why this might be? How can I make Streamlit refresh images too?