Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,47 +1,106 @@
|
|
1 |
import streamlit as st
|
|
|
2 |
import numpy as np
|
3 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
# μ λͺ©
|
6 |
-
st.title("
|
|
|
|
|
|
|
7 |
|
8 |
# ν
μ€νΈ μ
λ ₯
|
9 |
-
|
10 |
|
11 |
# μ«μ μ
λ ₯
|
12 |
-
number_input = st.number_input("μ«μλ₯Ό
|
13 |
|
14 |
-
#
|
15 |
-
|
16 |
|
17 |
-
#
|
18 |
-
|
19 |
|
20 |
-
#
|
21 |
-
|
22 |
-
st.write("체ν¬λ°μ€κ° μ νλμμ΅λλ€!")
|
23 |
|
24 |
-
#
|
25 |
-
|
26 |
-
|
|
|
|
|
27 |
|
28 |
# μ
λ νΈλ°μ€
|
29 |
-
|
30 |
-
st.write(f"λΉμ μ {option}μ μ ννμ΅λλ€.")
|
31 |
|
32 |
# λ©ν°μ
λ νΈ
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
# λ²νΌ
|
37 |
-
if st.button("
|
38 |
-
st.
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
#
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
fig, ax = plt.subplots()
|
46 |
-
ax.
|
47 |
st.pyplot(fig)
|
|
|
|
|
|
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.set_page_config(page_title="Streamlit UI Components", page_icon=":sparkles:")
|
10 |
|
11 |
# μ λͺ©
|
12 |
+
st.title("Streamlit UI Components μμ")
|
13 |
+
|
14 |
+
# λΆμ λͺ©
|
15 |
+
st.header("μ
λ ₯ μ»΄ν¬λνΈ")
|
16 |
|
17 |
# ν
μ€νΈ μ
λ ₯
|
18 |
+
text_input = st.text_input("ν
μ€νΈλ₯Ό μ
λ ₯νμΈμ")
|
19 |
|
20 |
# μ«μ μ
λ ₯
|
21 |
+
number_input = st.number_input("μ«μλ₯Ό μ
λ ₯νμΈμ", min_value=0, max_value=100)
|
22 |
|
23 |
+
# ν
μ€νΈ μμ
|
24 |
+
text_area = st.text_area("μ¬λ¬ μ€ ν
μ€νΈλ₯Ό μ
λ ₯νμΈμ")
|
25 |
|
26 |
+
# λ μ§ μ
λ ₯
|
27 |
+
date_input = st.date_input("λ μ§λ₯Ό μ ννμΈμ")
|
28 |
|
29 |
+
# μκ° μ
λ ₯
|
30 |
+
time_input = st.time_input("μκ°μ μ ννμΈμ")
|
|
|
31 |
|
32 |
+
# νμΌ μ
λ‘λ
|
33 |
+
uploaded_file = st.file_uploader("νμΌμ μ
λ‘λνμΈμ", type=["png", "jpg", "jpeg", "txt", "csv"])
|
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' λΉλμ€ νμΌμ΄ νμν©λλ€. ν΄λΉ νμΌμ΄ μλ€λ©΄ λΉλμ€ κ΄λ ¨ μ½λλ₯Ό μ£Όμ μ²λ¦¬νκ±°λ νμΌμ μ€λΉν΄μ£ΌμΈμ.
|