Run Streamlit apps from within python module
November 22, 2024
from streamlit.web import cli as stcli
client_path = os.path.join(root_dir, "client", "app.py")
if not os.path.exists(client_path):
raise FileNotFoundError(f"Could not find Streamlit app at: {client_path}")
sys.argv = [
"streamlit",
"run",
client_path,
"--server.port=6501",
"--server.address=localhost",
"--browser.serverAddress=localhost",
"--server.maxUploadSize=200"
]
sys.exit(stcli.main())
root_dir = os.path.dirname(os.path.abspath(file))
if root_dir not in sys.path: sys.path.insert(0, root_dir)