Spaces:
Sleeping
Sleeping
File size: 2,397 Bytes
a16ad43 2f0136f 8caf9d5 2a5d41a 2f0136f 2a5d41a 2f0136f 2a5d41a 2f0136f 2a5d41a 2f0136f 2a5d41a a16ad43 2a5d41a c9e23c5 2f0136f 2a5d41a |
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
import streamlit as st
from utils import generate_email
col1, col2=st.columns(2)
with col1:
with st.container(height=500):
with st.form("my_input", clear_on_submit=True, border=False):
st.write("Input")
# product
product=st.text_input("product", key="product")
# gender
gender=st.radio("gender", ["male", "female", "non-binary"], key="gender")
# profession
profession=st.text_input("profession", key="profession")
# hobby
hobby=st.text_input("hobby", key="hobby")
# Every form must have a submit button.
submitted = st.form_submit_button(label='Submit')
# if submitted:
# response = generate_email(st.session_state.product, st.session_state.gender, st.session_state.profession, st.session_state.hobby)
# st.session_state.email=response
with col2:
if submitted:
with st.spinner('Wait for it...'):
response = generate_email(st.session_state.product, st.session_state.gender, st.session_state.profession, st.session_state.hobby)
st.session_state.email=response
print("st.session_state.email")
print(st.session_state.email)
with st.container(height=500):
placeholder = st.empty()
# Replace the chart with several elements:
with placeholder.container():
st.write("Product: " + st.session_state.product)
st.write("Gender: " + st.session_state.gender)
st.write("Profession: " + st.session_state.profession)
st.write("Hobby: "+ st.session_state.hobby)
st.write("Email: "+ st.session_state.email)
if 'clicked' not in st.session_state:
st.session_state.clicked = False
def click_button():
st.session_state.clicked = True
st.button('Clear', on_click=click_button)
if st.session_state.clicked:
# The message and nested widget will remain on the page
del st.session_state.product
del st.session_state.gender
del st.session_state.profession
del st.session_state.hobby
del st.session_state.email
del st.session_state.clicked
if submitted:
placeholder.empty()
|