Create streamlit app. As per details 1. Create 2 columns 2.1st columns takes as inputs any types of streamlit codes. Then 3. In 2nd columns Show the page preview of that codes given in 1st columns. it works streamlit.io
To upload files, please first save the app
import streamlit as st
st.set_page_config(layout="wide")
# Create two columns
left_col, right_col = st.columns(2)
# Left column for code input
with left_col:
st.header("Input Streamlit Code")
code = st.text_area("Enter your Streamlit code here:", height=400,
value='''# Sample code
import streamlit as st
st.title("Hello Streamlit!")
st.write("This is a sample app.")
# Add a slider
value = st.slider("Select a value", 0, 100, 50)
st.write(f"Selected value: {value}")
# Add a checkbox
if st.checkbox("Show data"):
st.write("Here's some data!")
# Add a selectbox
option = st.selectbox("Choose an option", ["Option 1", "Option 2", "Option 3"])
st.write(f"You selected: {option}")
''')
# Right column for preview
with right_col:
st.header("Preview")
try:
# Create a separator for better visual organization
st.markdown("---")
# Execute the code and display the results
exec(code)
except Exception as e:
st.error(f"Error in code execution:\n{str(e)}")
# Add some helpful instructions at the bottom
st.markdown("---")
st.markdown("""
### Instructions:
1. Enter your Streamlit code in the left column
2. The preview will automatically update in the right column
3. If there are any errors, they will be displayed in the preview section
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?