Static json file serving

Hi experts,
I have published an app on Streamlit Cloud and I would like to expose a JSON file that the application generates based on user input. This file should then be rendered by a third-party app and embedded in my app through an iFrame.


navigator_url = f"https://third-party-app/#layerURL={json_url}"  
st.markdown(f'<iframe src="{navigator_url}" width="100%" height="600px"></iframe>', unsafe_allow_html=True)

The json file (json_url) is not persistent and is only valid for the current user session.

How to serve my json file in Streamlit cloud?

Thank you

If you need to serve files for users, the most straightforward way is to use Static file serving. You can create and destroy your JSON files in the appropriate directory. This wouldnโ€™t be secure, of course. You can use something like Named temporary files to manage creating and clearing files in the appropriate directory.

Thanks, I enabled this feature by setting up env variable in my VSC codespace. How to enable it in Streamlit cloud?

It works with my local istance but not in Streamlit cloud. I use this setting:

Is it correct?
Thank you

Itโ€™s enabled through your config.toml file and that screenshot is only for secrets.toml. Youโ€™ll need to save your config file into your repo. Since Streamlit Community Cloud executes streamlit run from the root of your repo, add a .streamlit directory to the root of your repo. Your config.toml file should be saved in that .streamlit directory. (Regardless of where your main app file lives in your repository, your configuration file should always be in .streamlit/config.toml in the root of your repository for Community Cloud to see it.)

1 Like