Spaces:
Runtime error
Runtime error
Hugo Garcia-Cotte
commited on
Commit
•
7a7b84a
1
Parent(s):
ef07da1
playing around with Streamli
Browse files
app.py
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
import streamlit as st
|
2 |
|
3 |
# Initialize a list of messages
|
4 |
-
|
|
|
|
|
5 |
|
6 |
# Create a text input field for users to enter their messages
|
7 |
user_input = st.text_input("Enter your message here:")
|
8 |
|
9 |
# Add user's message to the list when the submit button is clicked
|
10 |
if st.button("Submit"):
|
11 |
-
messages.append(user_input)
|
12 |
|
13 |
# Display the list of messages
|
14 |
st.write("List of messages:")
|
15 |
-
for msg in messages:
|
16 |
st.write("- " + msg)
|
17 |
|
18 |
|
|
|
1 |
import streamlit as st
|
2 |
|
3 |
# Initialize a list of messages
|
4 |
+
# Initialization
|
5 |
+
if 'messages' not in st.session_state:
|
6 |
+
st.session_state['messages'] = []
|
7 |
|
8 |
# Create a text input field for users to enter their messages
|
9 |
user_input = st.text_input("Enter your message here:")
|
10 |
|
11 |
# Add user's message to the list when the submit button is clicked
|
12 |
if st.button("Submit"):
|
13 |
+
st.session_state['messages'].append(user_input)
|
14 |
|
15 |
# Display the list of messages
|
16 |
st.write("List of messages:")
|
17 |
+
for msg in st.session_state['messages']:
|
18 |
st.write("- " + msg)
|
19 |
|
20 |
|