Created
July 4, 2023 16:40
-
-
Save dataprofessor/b995354d0d2ec38defc9566cc93de1fc to your computer and use it in GitHub Desktop.
Reload app upon removing an uploaded file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
if "input_option" not in st.session_state: | |
st.session_state.input_option = "Enter Text" | |
placeholder = st.empty() | |
# Defining title Font styling | |
with placeholder.container(): | |
st.session_state.input_option = st.radio("**Choose input option**", ('Enter Text', 'Upload Document'), horizontal= True) | |
if st.session_state.input_option == "Enter Text": | |
with st.container(): | |
text = st.text_area("**Enter text content to tag:**", height= 300, key= "text") | |
button = st.button("Submit") | |
if text or button: | |
response = get_text_content(text) | |
st.info(f'response: {",".join(response)}') | |
if st.session_state.input_option == "Upload Document": | |
uploaded_file = st.sidebar.file_uploader(label ="Upload a File", key= "uploaded_file", label_visibility= 'collapsed') | |
if uploaded_file is None: | |
st.warning('Please upload file in the sidebar!') | |
if uploaded_file is not None: | |
st.write(f'Uploaded file: {uploaded_file.name}') | |
else: | |
st.session_state.input_option = "Enter Text" | |
placeholder.container().empty() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment