Milind Kamat commited on
Commit
df73164
·
1 Parent(s): abbb230

Signed-off-by: Milind Kamat <36366961+milindkamat0507@users.noreply.github.com>

Files changed (1) hide show
  1. app.py +21 -20
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  from typing import List, Dict, Tuple, Optional, Any
3
-
4
  class StreamlitTutorial:
5
  """
6
  Main class for the Streamlit Tutorial application.
@@ -380,25 +380,26 @@ class StreamlitTutorial:
380
  index=0)""")
381
  ]
382
 
383
- def render_input_elements(self, col: st.delta_generator.DeltaGenerator) -> None:
384
- """
385
- Renders input examples with unique keys for both examples and live output
386
- """
387
- with col:
388
- st.markdown("### 📝 Code Examples")
389
- for idx, (title, code) in enumerate(self.get_input_elements()):
390
- with st.container(border=True, key=f"demo_container_{idx}"):
391
- st.markdown(f"**{title}**")
392
- st.code(code)
393
- st.markdown("Live output:")
394
-
395
- with st.container(border=True, key=f"output_container_{idx}"):
396
- try:
397
- # Create runtime version with unique key
398
- runtime_code = code.replace('demo_1', f'runtime_{idx}')
399
- exec(runtime_code)
400
- except Exception as e:
401
- st.error(f"Error: {str(e)}")
 
402
 
403
 
404
 
 
1
  import streamlit as st
2
  from typing import List, Dict, Tuple, Optional, Any
3
+ import traceback
4
  class StreamlitTutorial:
5
  """
6
  Main class for the Streamlit Tutorial application.
 
380
  index=0)""")
381
  ]
382
 
383
+ def render_input_elements(self, col: st.delta_generator.DeltaGenerator) -> None:
384
+ """
385
+ Renders input examples with unique keys for both examples and live output
386
+ """
387
+ with col:
388
+ st.markdown("### 📝 Code Examples")
389
+ for idx, (title, code) in enumerate(self.get_input_elements()):
390
+ with st.container(border=True, key=f"demo_container_{idx}"):
391
+ st.markdown(f"**{title}**")
392
+ st.code(code)
393
+ st.markdown("Live output:")
394
+
395
+ with st.container(border=True, key=f"output_container_{idx}"):
396
+ try:
397
+ # Create runtime version with unique key
398
+ runtime_code = code.replace('demo_1', f'runtime_{idx}')
399
+ exec(runtime_code)
400
+ except Exception as e:
401
+ st.error(f"Error: {str(e)}")
402
+
403
 
404
 
405