Spaces:
Runtime error
Runtime error
Commit
·
6697db8
1
Parent(s):
4d3ca32
Create code.py (#2)
Browse files- Create code.py (9639d9edb04be6c364854cff7120ea33f91dcdbc)
Co-authored-by: justin <[email protected]>
code.py
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from streamlit_embedcode import *
|
| 3 |
+
|
| 4 |
+
st.set_page_config(page_title="streamlit-embedcode documentation",)
|
| 5 |
+
|
| 6 |
+
choice = st.sidebar.radio(
|
| 7 |
+
"Please choose a function to see its documentation",
|
| 8 |
+
(
|
| 9 |
+
"Home",
|
| 10 |
+
"github_gist()",
|
| 11 |
+
"gitlab_snippet()",
|
| 12 |
+
"pastebin_snippet()",
|
| 13 |
+
"codepen_snippet()",
|
| 14 |
+
"ideone_snippet()",
|
| 15 |
+
"tagmycode_snippet()",
|
| 16 |
+
),
|
| 17 |
+
)
|
| 18 |
+
|
| 19 |
+
if choice == "Home":
|
| 20 |
+
"""
|
| 21 |
+
# streamlit-embedcode
|
| 22 |
+
|
| 23 |
+
[streamlit-embedcode](https://github.com/randyzwitch/streamlit-embedcode) is the easiest way to embed code snippets into your Streamlit app! This component supports the following code sharing services:
|
| 24 |
+
|
| 25 |
+
- [GitHub gist](https://gist.github.com/)
|
| 26 |
+
- [GitLab snippets](https://gitlab.com/explore/snippets)
|
| 27 |
+
- [Pastebin](https://pastebin.com/)
|
| 28 |
+
- [CodePen](https://codepen.io/)
|
| 29 |
+
- [Ideone](https://ideone.com/)
|
| 30 |
+
- [TagMyCode](https://tagmycode.com/)
|
| 31 |
+
|
| 32 |
+
---
|
| 33 |
+
|
| 34 |
+
## Installation
|
| 35 |
+
|
| 36 |
+
streamlit-embedcode is distributed via PyPI:
|
| 37 |
+
|
| 38 |
+
```python
|
| 39 |
+
pip install streamlit-embedcode
|
| 40 |
+
```
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## Examples
|
| 44 |
+
To see examples for each function, please select using the radio button in the sidebar.
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
elif choice == "github_gist()":
|
| 48 |
+
"""## github_gist()"""
|
| 49 |
+
|
| 50 |
+
github_gist
|
| 51 |
+
|
| 52 |
+
"---"
|
| 53 |
+
"### Example:"
|
| 54 |
+
with st.echo():
|
| 55 |
+
|
| 56 |
+
import streamlit as st
|
| 57 |
+
from streamlit_embedcode import github_gist
|
| 58 |
+
|
| 59 |
+
t = st.text_input(
|
| 60 |
+
"Enter GitHub gist URL:",
|
| 61 |
+
"https://gist.github.com/randyzwitch/934d502e53f2adcb48eea2423fe4a47e",
|
| 62 |
+
)
|
| 63 |
+
|
| 64 |
+
w = st.slider("width", 300, 800, 710)
|
| 65 |
+
github_gist(t, width=w)
|
| 66 |
+
|
| 67 |
+
elif choice == "gitlab_snippet()":
|
| 68 |
+
"""## gitlab_snippet()"""
|
| 69 |
+
|
| 70 |
+
gitlab_snippet
|
| 71 |
+
|
| 72 |
+
"---"
|
| 73 |
+
"### Example:"
|
| 74 |
+
with st.echo():
|
| 75 |
+
|
| 76 |
+
import streamlit as st
|
| 77 |
+
from streamlit_embedcode import gitlab_snippet
|
| 78 |
+
|
| 79 |
+
t = st.text_input(
|
| 80 |
+
"Enter GitLab snippet URL:", "https://gitlab.com/snippets/1995463",
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
w = st.slider("width", 300, 800, 710)
|
| 84 |
+
gitlab_snippet(t, width=w)
|
| 85 |
+
|
| 86 |
+
elif choice == "pastebin_snippet()":
|
| 87 |
+
"""## pastebin_snippet()"""
|
| 88 |
+
|
| 89 |
+
pastebin_snippet
|
| 90 |
+
|
| 91 |
+
"---"
|
| 92 |
+
"### Example:"
|
| 93 |
+
with st.echo():
|
| 94 |
+
|
| 95 |
+
import streamlit as st
|
| 96 |
+
from streamlit_embedcode import pastebin_snippet
|
| 97 |
+
|
| 98 |
+
t = st.text_input(
|
| 99 |
+
"Enter Pastebin snippet URL:", "https://pastebin.com/i1YQv94Q",
|
| 100 |
+
)
|
| 101 |
+
|
| 102 |
+
w = st.slider("width", 300, 800, 710)
|
| 103 |
+
pastebin_snippet(t, width=w)
|
| 104 |
+
|
| 105 |
+
elif choice == "codepen_snippet()":
|
| 106 |
+
"""## codepen_snippet()"""
|
| 107 |
+
|
| 108 |
+
codepen_snippet
|
| 109 |
+
|
| 110 |
+
"---"
|
| 111 |
+
"### Example:"
|
| 112 |
+
with st.echo():
|
| 113 |
+
|
| 114 |
+
import streamlit as st
|
| 115 |
+
from streamlit_embedcode import codepen_snippet
|
| 116 |
+
|
| 117 |
+
t = st.text_input(
|
| 118 |
+
"Enter CodePen snippet URL:", "https://codepen.io/ste-vg/pen/GRooLza",
|
| 119 |
+
)
|
| 120 |
+
|
| 121 |
+
w = st.slider("width", 300, 800, 750, key="1")
|
| 122 |
+
h = st.slider("height", 500, 800, 600, key="2")
|
| 123 |
+
codepen_snippet(t, width=w, height=h)
|
| 124 |
+
|
| 125 |
+
elif choice == "ideone_snippet()":
|
| 126 |
+
"""## ideone_snippet()"""
|
| 127 |
+
|
| 128 |
+
ideone_snippet
|
| 129 |
+
|
| 130 |
+
"---"
|
| 131 |
+
"### Example:"
|
| 132 |
+
with st.echo():
|
| 133 |
+
|
| 134 |
+
import streamlit as st
|
| 135 |
+
from streamlit_embedcode import ideone_snippet
|
| 136 |
+
|
| 137 |
+
t = st.text_input("Enter Ideone snippet URL:", "https://ideone.com/vQ54cr",)
|
| 138 |
+
|
| 139 |
+
w = st.slider("width", 300, 800, 710, key="1")
|
| 140 |
+
ideone_snippet(t, width=w)
|
| 141 |
+
|
| 142 |
+
elif choice == "tagmycode_snippet()":
|
| 143 |
+
"""## tagmycode_snippet()"""
|
| 144 |
+
|
| 145 |
+
tagmycode_snippet
|
| 146 |
+
|
| 147 |
+
"---"
|
| 148 |
+
"### Example:"
|
| 149 |
+
with st.echo():
|
| 150 |
+
|
| 151 |
+
import streamlit as st
|
| 152 |
+
from streamlit_embedcode import tagmycode_snippet
|
| 153 |
+
|
| 154 |
+
t = st.text_input(
|
| 155 |
+
"Enter Ideone snippet URL:",
|
| 156 |
+
"https://tagmycode.com/snippet/5965/recursive-list-files-in-a-dir#.Xwyc43VKglU",
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
w = st.slider("width", 300, 800, 710, key="1")
|
| 160 |
+
tagmycode_snippet(t, width=w)
|