Where are saved files?

Hi, I have created an app to allow users to enter recipes which are saved in a file, then this file will be used for statistics. The app seems to work, but I don’t know where the file is. The line of code is simply:

json.dump (object, file)

thank you

Hi @Fabio_Pasquarella -

Could you be a bit more specific? Where are you deploying your app, and what is the value of file you are providing in your code?

Best,
Randy

@randyzwitch this is my app:

https://share.streamlit.io/toccalenuvole73/freezingapp_project/main/freezingapp_project.py

here is the code:

thank you

To answer the general question, the files will be written in the current work directory, which for Streamlit sharing is the top-level if I’m not mistaken.

But specifically for Streamlit sharing, this isn’t a good development pattern. Apps are deployed in containers, which may restart at any time or may have multiple replicas to serve higher volume of traffic. In that case, your files will only be local to the container where they were written.

It looks like you’re collecting data from users…with Streamlit sharing now supporting secrets management, a better pattern would be to write the data to a persistent location such as Google Drive or Amazon S3, so that these files will persist beyond any specific container on Streamlit sharing.

Best,
Randy

1 Like

@randyzwitch could you please give some advice on how to write a file to gdrive? Thank you

This appears to be a reasonably complete example:

https://medium.com/@annissouames99/how-to-upload-files-automatically-to-drive-with-python-ee19bb13dda

1 Like