Chai Maker App - Streamlit

Anand ShindeAnand Shinde
2 min read

In the second chapter, we are learning how to use some conditional statements in Streamlit.

if st.button("Make Chai"):
    st.success("Your chai is being brewed")

add_masala = st.checkbox("Add Masala")

It shows a button named ‘Add Masala’. There’s no need to do any external design — it’s already beautiful. When you click the button, it returns True that’s why runs st.success, which shows the message: ‘Your chai is being brewed’

slider

Another interesting component is the slider.

sugar = st.slider("Sigar level (spoon)",0,5,2)

In this code, we display a slider using st.slider(label, min_value=None, max_value=None, value=None).
It accepts four values:

  1. label – the text label for the slider

  2. min_value – the starting number of the slider

  3. max_value – the maximum value for the slider

  4. value – the default starting number

number_input – Use this when you need to accept a number.

text_input – Use this when you need to accept text.

Full code :

import streamlit as st

st.title("chai Maker App")


if st.button("Make Chai"):
    st.success("Your chai is being brewed")

add_masala = st.checkbox("Add Masala")

if add_masala:
    st.write("Masala added to your chai")

tea_type = st.radio("Pick your chai base: ",["Milk","Water","Almond Milk"])

st.write(f"your selected {tea_type}")

favour = st.selectbox("Choose flavour:",["Adrak","kesar","tulshi"])

st.write(f"selected Flavor {favour}")

sugar = st.slider("Sigar level (spoon)",0,5,2)

st.write(f"Selected sugar spoon {sugar}")

cups= st.number_input("How many cups",min_value=1,max_value=10,step=1)
st.write(f"cup you orders {cups}")

name = st.text_input("Enter your name")

if name :
    st.write(f"Welcome {name}! your coppy on the way")

preview

video

Source code

github: https://github.com/mr-AnandShinde-358/chai-streamlit

Reference:

Chai aur code - Youtube channel : https://www.youtube.com/@chaiaurcode

streamlit doc - https://docs.streamlit.io/

1
Subscribe to my newsletter

Read articles from Anand Shinde directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Anand Shinde
Anand Shinde

Full-Stack Developer | JavaScript, React, Next.js, MongoDB Specialist | Building Dynamic & High-Performance Web Applications