vsj0702 commited on
Commit
fc252a3
·
verified ·
1 Parent(s): fdb0bde

restoration in progress

Browse files
Files changed (1) hide show
  1. app.py +19 -30
app.py CHANGED
@@ -95,40 +95,29 @@ with bot:
95
  st.session_state.get("error_output", "")
96
  )
97
 
98
- # 7️⃣ Input section
99
- # Allow users to specify runtime inputs (comma-separated)
100
- st.session_state.setdefault('user_inputs', '')
101
- user_inputs = st.text_input(
102
- "🔢 Enter input values (comma-separated)",
103
- value=st.session_state.user_inputs,
104
- help="E.g., 5,7 for two numbers"
105
  )
106
- st.session_state.user_inputs = user_inputs
107
-
108
- # Update run button to pass inputs into code execution
109
- if st.button("▶️ Run"):
110
- # If user provided inputs, inject into code via input() override
111
- exec_code = code
112
- if user_inputs:
113
- # Prepare input simulation
114
- values = user_inputs.split(',')
115
- input_stub = '
116
- '.join([f"print({v.strip()})" for v in values])
117
- exec_code = f"{input_stub}
118
- " + code
119
- out, err, exc = execute_code(exec_code)
120
- st.session_state.code_output = out
121
- st.session_state.error_output = err or exc
122
-
123
- # Display results
124
- if st.session_state.get("code_output"):
125
- st.text_area("Output", st.session_state.code_output, height=120)
126
- if st.session_state.get("error_output"):
127
- st.error(st.session_state.error_output)
128
 
129
  # 8️⃣ Footer
130
  st.markdown(f"""
131
  <div style='text-align:center; margin-top:1rem; color:{TEXT}66;'>
132
  Built with ❤️ & Streamlit
133
  </div>
134
- """, unsafe_allow_html=True)
 
95
  st.session_state.get("error_output", "")
96
  )
97
 
98
+ # 7️⃣ Export section
99
+ st.markdown("---")
100
+ st.subheader("Export")
101
+ export_data = export_session(
102
+ code,
103
+ st.session_state.get("code_output", ""),
104
+ st.session_state.get("error_output", "")
105
  )
106
+ col1, col2 = st.columns(2)
107
+ with col1:
108
+ st.download_button(
109
+ "📦 JSON",
110
+ data=json.dumps(export_data, indent=2),
111
+ file_name="session.json",
112
+ mime="application/json"
113
+ )
114
+ with col2:
115
+ txt = f"# Code\n{code}\n\n# Output\n{st.session_state.get('code_output','')}\n\n# Errors\n{st.session_state.get('error_output','')}"
116
+ st.download_button("📝 Text", txt, "session.txt", "text/plain")
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  # 8️⃣ Footer
119
  st.markdown(f"""
120
  <div style='text-align:center; margin-top:1rem; color:{TEXT}66;'>
121
  Built with ❤️ & Streamlit
122
  </div>
123
+ """, unsafe_allow_html=True)