File size: 875 Bytes
96f0aad
 
 
8243d0b
96f0aad
8243d0b
 
 
 
96f0aad
8243d0b
 
96f0aad
8243d0b
 
96f0aad
8243d0b
 
 
96f0aad
8243d0b
 
 
 
 
 
 
96f0aad
8243d0b
 
 
 
 
 
f271975
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import streamlit as st

# Set the title of the app
st.title("Basic Streamlit App with Form")

# Create a form
with st.form("user_form"):
    # Display a header
    st.header("Welcome to Streamlit Form!")

    # Add a text input widget
    user_input = st.text_input("Enter your name:")

    # Add a slider widget
    age = st.slider("Select your age:", 0, 100, 25)

    # Add form buttons
    submit_button = st.form_submit_button("Submit")
    clear_button = st.form_submit_button("Clear")

# Handle form submission
if submit_button:
    if user_input:
        st.success(f"Hello, {user_input}!")
        st.info(f"You are {age} years old.")
    else:
        st.error("Please enter your name.")

# Handle form clearing
if clear_button:
    # Re-run the app to reset the form
    st.experimental_rerun()

# Display an image
st.image("./nadi-lok-image.png", caption="Image")