When running locally, I had no issues. However, once deployed, the app started to not behave the way I anticipated.
I deployed it in local internal server.
Python version: 3.11.5
Streamlit version: 1.31.0
For some info, when my app begins, it uses the date the app got initiated to make an updated query. Using this query, I successfully retrieve information from a DB.
In addition, I also added a “reload” button to reinitiate the process in case the data is not up-to-date. (I build this in case the deployed app did not have updated data)
However, ever since I deployed the app, the data has not been updated. Furthermore, the reload/rerun functionality doesn’t seem to work. However, every other widgets work fine.
I’m guessing this issue is due to
caching
streamlit losing its capability to rerun the script once deployed
Can you share a minimal, executable code snippet or link to your repository?
st.rerun works fine both locally and remotely, but it’s difficult to provide guidance without understanding how you are reading, writing, and caching your data.
So your saying for example if i had a button in streamlit, that when clicked the st.rerun() function is ran, the code will reload even if the app is deployed, i previously though that st.rerun() doesn’t work on deployed apps
Hi @JibreelOG. All Streamlit functions should work the same both for local and deployed apps. That holds true for st.rerun. The thing that might trip people up is environment configuration and access to local files.
Local files
When you deploy an app to a cloud service, the Python code is running on some remote machine. Any file paths it works with will be on the remote machine. For Community Cloud (for example), if you don’t include a file in your repository or you use global paths in your app, then your deployed app won’t work as it did locally.
Environment configuration
If you don’t install all the necessary Python packages (or any additional software) on the remote machine running your, then it won’t function.
You can read more about the client-server structure of Streamlit, but I can’t think of any function that wouldn’t work the same for local and deployed apps.
thankyou for the detailed response,
is it possible to deploy my streamlit app on my own server? For example a reaspberry pi so all my local files are still accesible for the program
Yes, you can deploy your app elsewhere. There are a few threads on the forum about making Raspberry Pi work. IIRC, I managed to get a Streamlit app running on a Raspberry Pi once, but there were a few particulars like using a Linux OS and I think miniconda… (it’s been a while).
Aside from deploying elsewhere where you have more control over the files, a general solution is to either include your data file in your repo so it’s copied along with your app code, or host your data file somewhere. If you have some sort of spreadsheet or CSV file you need, you could indeed use Google Sheets for that.
I don’t know what’s happening in your invoke_api method. It could be relying on a local cookie for authentication, and that’s why it’s working locally and not when deployed. You’ll need to investigate the dependencies within invoke_api to make sure a deployed app has access to everything it needs.
One additional note: Apps on Community Cloud can get hit with rate limits since public APIs can’t distinguish one app from another. If you’re using a public API and others on Community Cloud are using that same public API, it might not work because of rate limiting.
is just a get request to an internal public api that has no auth and very low traffic. The issue was the the rerun was not working as expected and it keeps looping. Even after getting the output in that block of button
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.