martianband1t commited on
Commit
8337efe
1 Parent(s): d13213c

Create utils.py

Browse files
Files changed (1) hide show
  1. utils.py +14 -0
utils.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import inspect
2
+ import textwrap
3
+
4
+ import streamlit as st
5
+
6
+
7
+ def show_code(demo):
8
+ """Showing the code of the demo."""
9
+ show_code = st.sidebar.checkbox("Show code", True)
10
+ if show_code:
11
+ # Showing the code of the demo.
12
+ st.markdown("## Code")
13
+ sourcelines, _ = inspect.getsourcelines(demo)
14
+ st.code(textwrap.dedent("".join(sourcelines[1:])))