Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,106 +1,29 @@
|
|
1 |
import streamlit as st
|
2 |
-
import pandas as pd
|
3 |
-
import numpy as np
|
4 |
-
import matplotlib.pyplot as plt
|
5 |
-
from PIL import Image
|
6 |
-
import io
|
7 |
|
8 |
-
#
|
9 |
-
st.
|
10 |
-
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
#
|
21 |
-
|
22 |
-
|
23 |
-
#
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
# μ¬λΌμ΄λ
|
36 |
-
slider = st.slider("μ¬λΌμ΄λλ₯Ό μ‘°μ νμΈμ", 0, 100, 50)
|
37 |
-
|
38 |
-
# μ
λ νΈλ°μ€
|
39 |
-
selectbox = st.selectbox("μ΅μ
μ μ ννμΈμ", ["μ΅μ
1", "μ΅μ
2", "μ΅μ
3"])
|
40 |
-
|
41 |
-
# λ©ν°μ
λ νΈ
|
42 |
-
multiselect = st.multiselect("μ¬λ¬ μ΅μ
μ μ ννμΈμ", ["μ΅μ
A", "μ΅μ
B", "μ΅μ
C"])
|
43 |
-
|
44 |
-
# λΌλμ€ λ²νΌ
|
45 |
-
radio = st.radio("λΌλμ€ λ²νΌμμ μ ννμΈμ", ["μ ν 1", "μ ν 2", "μ ν 3"])
|
46 |
-
|
47 |
-
# 체ν¬λ°μ€
|
48 |
-
checkbox = st.checkbox("체ν¬λ°μ€λ₯Ό μ ννμΈμ")
|
49 |
-
|
50 |
-
# λ²νΌ
|
51 |
-
if st.button("ν΄λ¦νμΈμ"):
|
52 |
-
st.success("λ²νΌμ΄ ν΄λ¦λμμ΅λλ€!")
|
53 |
-
|
54 |
-
st.header("μΆλ ₯ μ»΄ν¬λνΈ")
|
55 |
-
|
56 |
-
# ν
μ€νΈ μΆλ ₯
|
57 |
-
st.write("μ¬κΈ°μ ν
μ€νΈλ₯Ό μΆλ ₯ν©λλ€.")
|
58 |
-
|
59 |
-
# λ°μ΄ν°νλ μ μΆλ ₯
|
60 |
-
df = pd.DataFrame({
|
61 |
-
'column 1': [1, 2, 3, 4],
|
62 |
-
'column 2': [10, 20, 30, 40]
|
63 |
-
})
|
64 |
-
st.dataframe(df)
|
65 |
-
|
66 |
-
# μ°¨νΈ
|
67 |
-
chart_data = pd.DataFrame(np.random.randn(20, 3), columns=['a', 'b', 'c'])
|
68 |
-
st.line_chart(chart_data)
|
69 |
-
|
70 |
-
# κ·Έλ¦Ό μΆλ ₯
|
71 |
-
if uploaded_file is not None and uploaded_file.type.startswith("image/"):
|
72 |
-
image = Image.open(uploaded_file)
|
73 |
-
st.image(image, caption="Uploaded Image")
|
74 |
-
|
75 |
-
# λΉλμ€ μΆλ ₯
|
76 |
-
video_file = open('example.mp4', 'rb')
|
77 |
-
video_bytes = video_file.read()
|
78 |
-
st.video(video_bytes)
|
79 |
-
|
80 |
-
# μ½λ μΆλ ₯
|
81 |
-
code = '''def hello():
|
82 |
-
print("Hello, Streamlit!")'''
|
83 |
-
st.code(code, language='python')
|
84 |
-
|
85 |
-
# 맡
|
86 |
-
map_data = pd.DataFrame({
|
87 |
-
'lat': np.random.randn(10) + 37.76, # μνλμμ€μ½ μλ μ£Όλ³
|
88 |
-
'lon': np.random.randn(10) - 122.4 # μνλμμ€μ½ κ²½λ μ£Όλ³
|
89 |
-
})
|
90 |
-
st.map(map_data)
|
91 |
-
|
92 |
-
# μ§νλ°
|
93 |
-
import time
|
94 |
-
progress_bar = st.progress(0)
|
95 |
-
for i in range(100):
|
96 |
-
time.sleep(0.1)
|
97 |
-
progress_bar.progress(i + 1)
|
98 |
-
|
99 |
-
st.header("μ°¨νΈ μμ")
|
100 |
-
|
101 |
-
# λ§λ μ°¨νΈ
|
102 |
-
fig, ax = plt.subplots()
|
103 |
-
ax.bar(["A", "B", "C"], [10, 20, 15])
|
104 |
-
st.pyplot(fig)
|
105 |
-
|
106 |
-
# μ£Όμ: μ€μ μ½λ μ€νμ μν΄μλ 'example.mp4' λΉλμ€ νμΌμ΄ νμν©λλ€. ν΄λΉ νμΌμ΄ μλ€λ©΄ λΉλμ€ κ΄λ ¨ μ½λλ₯Ό μ£Όμ μ²λ¦¬νκ±°λ νμΌμ μ€λΉν΄μ£ΌμΈμ.
|
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
# μ¬μ΄λλ° νμ΄ν
|
4 |
+
st.sidebar.title("μ μ΄μ λ©λ΄")
|
5 |
+
|
6 |
+
# λ©λ΄ νλͺ©κ³Ό νμ νλͺ© μ μ
|
7 |
+
menus = {
|
8 |
+
"A": ["A-1", "A-2", "A-3"],
|
9 |
+
"B": ["B-1", "B-2", "B-3"],
|
10 |
+
"C": ["C-1", "C-2", "C-3"],
|
11 |
+
"D": ["D-1", "D-2", "D-3"],
|
12 |
+
"E": ["E-1", "E-2", "E-3"],
|
13 |
+
}
|
14 |
+
|
15 |
+
# μ νλ λ©λ΄λͺ
μ μ μ₯ν λ³μ
|
16 |
+
selected_menu = None
|
17 |
+
|
18 |
+
# κ° λ©λ΄μ λν΄ μ¬μ΄λλ°μ μ μ΄μ λ©λ΄ μμ±
|
19 |
+
for menu in menus:
|
20 |
+
with st.sidebar.expander(menu):
|
21 |
+
for sub_menu in menus[menu]:
|
22 |
+
if st.button(sub_menu, key=sub_menu): # κ³ μ ν keyλ₯Ό μ 곡νμ¬ κ° λ²νΌμ ꡬλ³
|
23 |
+
selected_menu = sub_menu
|
24 |
+
|
25 |
+
# μ νλ λ©λ΄λͺ
μΆλ ₯
|
26 |
+
if selected_menu:
|
27 |
+
st.write(f"μ νλ λ©λ΄: {selected_menu}")
|
28 |
+
else:
|
29 |
+
st.write("λ©λ΄λ₯Ό μ νν΄μ£ΌμΈμ.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|