Spaces:
Sleeping
Sleeping
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") | |