Spaces:
Runtime error
Runtime error
import streamlit as st | |
import pexpect | |
import time | |
# Initialize a list of messages | |
# Initialization | |
if 'messages' not in st.session_state: | |
st.session_state['messages'] = [] | |
if 'child' not in st.session_state: | |
st.session_state['child'] = pexpect.spawn("python danse_macabre.py", encoding='utf-8', timeout=None) | |
child = st.session_state['child'] | |
child.expect(">>>>>") | |
st.session_state['messages'].append(child.before) | |
# Create a text input field for users to enter their messages | |
user_input = st.text_input("Enter your message here:") | |
# Add user's message to the list when the submit button is clicked | |
if st.button("Submit"): | |
st.session_state['messages'].append(user_input) | |
child.sendline(user_input) | |
# Display the list of messages | |
st.write("List of messages:") | |
for msg in st.session_state['messages']: | |
st.write(msg) | |
""" | |
# Start the other program | |
child = pexpect.spawn("python DO_NOT_COMMIT.py", encoding='utf-8', timeout=None) | |
while True: | |
child.expect(">>>>>") | |
print(child.before) | |
child.sendline(input(">>>>>"))""" | |