“Local” is a relative term. From the point of view of the application, it is always running locally and it is the requests that can come from the outside or not. I guess the web server knows whether that is the case, but there are no stable API to access the server from streamlit.
I suggest making the application take a command line parameter, let’s say --allow-training
, to control whether the training interface should be visible or not.