Automatically refresh page

So my app needed to update every 10 to 20 seconds to see changes on a local file. I am using streamlit to process and visualise data from test equipment and I do not want the user to have to press the refresh button every time.

I tried st.experimental_rerun() and it is awesome for some things, but does not work in this case as it will just rerun endlessly.

My solution now is the following code:

from selenium import webdriver
import time

x = "http://localhost:8501/"
refreshrate =10
refreshrate = int(refreshrate)
driver = webdriver.Chrome(executable_path="C:\\Users\\z0044wmy\\Desktop\\chromedriver_win32\\chromedriver.exe")


while True:

It requires download of the chrome driver: Downloads - ChromeDriver - WebDriver for Chrome

I cant say i love this solution, but it does work.
I can use Popen(‘’, shell=True) to make sure this code runs in paralel.
A big downside is that lineedits are also refreshed mid-edit…

Anyone have any better ideas?

Hi @Ruben_S,

@kmcgrady has created a custom component called Streamlit Autorefresh to solve exactly this problem! :slight_smile:

Here are the links to the announcement and GitHub repo:

Happy Streamlit’ing! :balloon:

Thanks for the feedback!
Sadly I got following error: To use Custom Components in Streamlit, you need to install PyArrow. Unfortunately, PyArrow does not yet support Python 3.9.

Downgrading to 3.8 is clearly a possible fix, but for now I will refrain as it might affect other things.

Cross posting from the autorefresh post, but When Python 3.9 was released, PyArrow (which facilitates a serialization of pandas dataframes) did not support it. We added this error to inform users of this. It seems to be addressed, and we have removed it for the next release. You can try out pip install streamlit-nightly if you want to keep working on Python 3.9, or you can try using Python 3.8 using a tool like pyenv

Hope that helps!

1 Like