Streamlit is an open source app framework in python language. It helps us create beautiful web-apps for data science and machine learning in a little time. It is compatible with major python libraries such as scikit-learn, keras, pytorch, latex, numpy, pandas, matplotlib, etc.. Syntax for installing this library is shown below.
Install StreamLit –
In the command-prompt type
pip install streamlit
Creating a Simple application (Hello World) –
The 'hello, world!' script in Streamlit: streamlit hello # to run your python script streamlit run myFirstStreamlitApp.py
You can stop running your app any time using Ctrl + C.
Advantages:
1. It embraces python-scripting.
2. Less code is needed to create amazing web-apps.
3. No callbacks are needed since widgets are treated as variables.
4. Data caching simplifies and speeds up computation pipelines.
Disadvantages:
1. Streamlit’s Data caching cannot keep track of changes to the data happening outside the function body.
Some of its basic functions are described here.
1. Adding a Title
# myFirstStreamlitApp.py #import the library import streamlit as stl # add title to your app stl.title( "Geeks for Geeks" ) |
Output:
2. Adding some text
# myFirstStreamlitApp.py #import the library import streamlit as stl # add title to your app stl.title( "Geeks for Geeks" ) #adding text to your app stl.write( "A Computer Science portal for Geeks" ) |
Output:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.