counter
To upload files, please first save the app
import streamlit as st
# Set page title
st.title("Simple Counter App")
# Initialize counter in session state if it doesn't exist
if "count" not in st.session_state:
st.session_state.count = 0
# Display current count
st.header(f"Current Count: {st.session_state.count}")
# Create columns for buttons
col1, col2, col3 = st.columns(3)
# Increment button
with col1:
if st.button("Increment (+1)"):
st.session_state.count += 1
st.rerun()
# Decrement button
with col2:
if st.button("Decrement (-1)"):
st.session_state.count -= 1
st.rerun()
# Reset button
with col3:
if st.button("Reset"):
st.session_state.count = 0
st.rerun()
# Add a custom increment input
st.subheader("Custom Increment")
col1, col2 = st.columns([3, 1])
with col1:
increment_value = st.number_input("Enter a value to add/subtract:", value=0, step=1)
with col2:
if st.button("Apply"):
st.session_state.count += increment_value
st.rerun()
# Add a small footer
st.markdown("---")
st.caption("A simple counter application built with Streamlit")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?