How can I invoke streamlit from within python code?

Hello Folks,

What is the best means to invoke streamlit from within python code ?
I dont want to go via the CLI route of streamlit run <>

This link has some reference, but again to invoke as mentioned in link, python click context is needed.


Looks like this is a way:

import os
import streamlit.bootstrap
from streamlit import config as _config

dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, '')

_config.set_option("server.headless", True)
args = []

#streamlit.cli.main_run(filename, args),'',args)
1 Like