Hi, community,
I am creating a web app that will execute commands in the terminal. While I am figuring out how to do that, I wanted to get UI under control. I have a simple text box followed by a button. On clicking the button, the command gets executed.
Before getting into complex stuff, I thought to create a simple button that displays text on clicking. My question is do I have to use session state? Is there any other way to use onClick?
This is what I have coded so far:
import streamlit as st
import subprocess
def CreateProject(name):
st.session_state.count = 1
st.write("Project is created. Name: "+name)
if 'count' not in st.session_state:
st.session_state.count =0
name = st.text_input("Please provide project name")
btn=st.button("Create project",on_click=CreateProject,args=(name,))
st.write('count=',st.session_state.count)