Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -173,7 +173,42 @@ def inject_background_toggle_js():
|
|
173 |
"""
|
174 |
html(js_code, height=0, width=0)
|
175 |
|
176 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
if 'contents' not in st.session_state:
|
178 |
# contents ํด๋ ๋ด์ ๋ชจ๋ ์ด๋ฏธ์ง ํ์ผ ๋ก๋
|
179 |
if not os.path.exists('contents'):
|
@@ -197,11 +232,13 @@ if 'fit_mode' not in st.session_state:
|
|
197 |
if 'app_loaded' not in st.session_state:
|
198 |
st.session_state.app_loaded = False
|
199 |
|
|
|
200 |
if 'fixed_image_enabled' not in st.session_state:
|
201 |
st.session_state.fixed_image_enabled = False
|
202 |
|
203 |
-
if 'fixed_image_path' not in st.session_state:
|
204 |
-
st.session_state.fixed_image_path = None
|
|
|
205 |
|
206 |
# ์ฌ๋ผ์ด๋์ผ ์๋ ์์ ๋ก์ง
|
207 |
if not st.session_state.app_loaded and not st.session_state.get('preview_mode', False):
|
@@ -376,6 +413,26 @@ with st.sidebar:
|
|
376 |
st.session_state.activate_fullscreen = False
|
377 |
st.rerun()
|
378 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
# ๋ฉ์ธ ์ปจํ
์ธ ์์ญ
|
380 |
if st.session_state.get('preview_mode', False):
|
381 |
# ํ๊น
ํ์ด์ค UI ์์ ์จ๊ธฐ๊ธฐ ์ํ CSS ์ถ๊ฐ
|
@@ -558,4 +615,3 @@ else:
|
|
558 |
# use_column_width=True๋ฅผ use_container_width=True๋ก ๋ณ๊ฒฝ
|
559 |
st.image(img_path, caption=os.path.basename(img_path), use_container_width=True)
|
560 |
|
561 |
-
|
|
|
173 |
"""
|
174 |
html(js_code, height=0, width=0)
|
175 |
|
176 |
+
# URL ํ๋ผ๋ฏธํฐ ์ฒ๋ฆฌ
|
177 |
+
try:
|
178 |
+
query_params = st.query_params
|
179 |
+
|
180 |
+
# ์ ์ฒดํ๋ฉด ๋ชจ๋ ํ์ธ
|
181 |
+
if "fullscreen" in query_params and query_params["fullscreen"][0].lower() == "true":
|
182 |
+
st.session_state.preview_mode = True
|
183 |
+
st.session_state.activate_fullscreen = True
|
184 |
+
|
185 |
+
# ์ด๋ฏธ์ง ์ ํ ๋ชจ๋ ํ์ธ
|
186 |
+
if "change" in query_params:
|
187 |
+
st.session_state.fixed_image_enabled = False
|
188 |
+
|
189 |
+
# ๋จ์ผ ์ด๋ฏธ์ง ๋ชจ๋ ํ์ธ
|
190 |
+
if "1image" in query_params:
|
191 |
+
st.session_state.fixed_image_enabled = True
|
192 |
+
|
193 |
+
# ํน์ ์ด๋ฏธ์ง ์ธ๋ฑ์ค๊ฐ ์ง์ ๋์๋์ง ํ์ธ
|
194 |
+
if "image" in query_params and query_params["image"][0].isdigit():
|
195 |
+
img_index = int(query_params["image"][0])
|
196 |
+
|
197 |
+
# contents ํด๋ ๋ด์ ๋ชจ๋ ์ด๋ฏธ์ง ํ์ผ ๋ฏธ๋ฆฌ ๋ก๋
|
198 |
+
if not os.path.exists('contents'):
|
199 |
+
os.makedirs('contents')
|
200 |
+
|
201 |
+
image_files = glob.glob('contents/*.jpg') + glob.glob('contents/*.jpeg') + glob.glob('contents/*.png')
|
202 |
+
|
203 |
+
# ์ธ๋ฑ์ค๊ฐ ์ ํจํ์ง ํ์ธ
|
204 |
+
if 0 <= img_index < len(image_files):
|
205 |
+
st.session_state.fixed_image_path = image_files[img_index]
|
206 |
+
elif image_files: # ์ ํจํ์ง ์์ง๋ง ์ด๋ฏธ์ง๊ฐ ์๋ ๊ฒฝ์ฐ ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง ์ฌ์ฉ
|
207 |
+
st.session_state.fixed_image_path = image_files[0]
|
208 |
+
except Exception as e:
|
209 |
+
st.error(f"URL ํ๋ผ๋ฏธํฐ ์ฒ๋ฆฌ ์ค ์ค๋ฅ ๋ฐ์: {e}")
|
210 |
+
|
211 |
+
# ์ด๊ธฐ ์ค์ ๋ฐ ์ํ ๊ด๋ฆฌ (๊ธฐ์กด ์ฝ๋ ์์ )
|
212 |
if 'contents' not in st.session_state:
|
213 |
# contents ํด๋ ๋ด์ ๋ชจ๋ ์ด๋ฏธ์ง ํ์ผ ๋ก๋
|
214 |
if not os.path.exists('contents'):
|
|
|
232 |
if 'app_loaded' not in st.session_state:
|
233 |
st.session_state.app_loaded = False
|
234 |
|
235 |
+
# ๊ธฐ์กด ์ฝ๋๋ฅผ ์กฐ๊ฑด๋ถ๋ก ์์
|
236 |
if 'fixed_image_enabled' not in st.session_state:
|
237 |
st.session_state.fixed_image_enabled = False
|
238 |
|
239 |
+
if 'fixed_image_path' not in st.session_state and st.session_state.contents:
|
240 |
+
st.session_state.fixed_image_path = st.session_state.contents[0] if st.session_state.contents else None
|
241 |
+
|
242 |
|
243 |
# ์ฌ๋ผ์ด๋์ผ ์๋ ์์ ๋ก์ง
|
244 |
if not st.session_state.app_loaded and not st.session_state.get('preview_mode', False):
|
|
|
413 |
st.session_state.activate_fullscreen = False
|
414 |
st.rerun()
|
415 |
|
416 |
+
# ์ฌ์ด๋๋ฐ ํ๋จ์ URL ์ ๋ณด ์ถ๊ฐ
|
417 |
+
st.sidebar.markdown("---")
|
418 |
+
st.sidebar.subheader("์ ์ URL")
|
419 |
+
|
420 |
+
base_url = "https://jamespark3-display.hf.space/"
|
421 |
+
|
422 |
+
# ์ด๋ฏธ์ง ์ ํ ๋ชจ๋ URL
|
423 |
+
transition_url = f"{base_url}?fullscreen=true&change"
|
424 |
+
st.sidebar.text_area("์ด๋ฏธ์ง ์ ํ ๋ชจ๋", transition_url, help="์ด URL๋ก ์ ์ํ๋ฉด ์๋์ผ๋ก ์ด๋ฏธ์ง ์ ํ ๋ชจ๋๋ก ์์๋ฉ๋๋ค.")
|
425 |
+
|
426 |
+
# ๋จ์ผ ์ด๋ฏธ์ง ๋ชจ๋ URL
|
427 |
+
if st.session_state.fixed_image_enabled and st.session_state.fixed_image_path and st.session_state.contents:
|
428 |
+
current_img_index = st.session_state.contents.index(st.session_state.fixed_image_path) if st.session_state.fixed_image_path in st.session_state.contents else 0
|
429 |
+
single_url = f"{base_url}?fullscreen=true&1image&image={current_img_index}"
|
430 |
+
st.sidebar.text_area("ํ์ฌ ์ ํ๋ ์ด๋ฏธ์ง ๋ชจ๋", single_url, help="์ด URL๋ก ์ ์ํ๋ฉด ์ ํ๋ ์ด๋ฏธ์ง๋ง ํ์๋ฉ๋๋ค.")
|
431 |
+
else:
|
432 |
+
single_url = f"{base_url}?fullscreen=true&1image"
|
433 |
+
st.sidebar.text_area("๋จ์ผ ์ด๋ฏธ์ง ๋ชจ๋", single_url, help="์ด URL๋ก ์ ์ํ๋ฉด ์ฒซ ๋ฒ์งธ ์ด๋ฏธ์ง๊ฐ ๊ณ ์ ๋์ด ํ์๋ฉ๋๋ค.")
|
434 |
+
|
435 |
+
|
436 |
# ๋ฉ์ธ ์ปจํ
์ธ ์์ญ
|
437 |
if st.session_state.get('preview_mode', False):
|
438 |
# ํ๊น
ํ์ด์ค UI ์์ ์จ๊ธฐ๊ธฐ ์ํ CSS ์ถ๊ฐ
|
|
|
615 |
# use_column_width=True๋ฅผ use_container_width=True๋ก ๋ณ๊ฒฝ
|
616 |
st.image(img_path, caption=os.path.basename(img_path), use_container_width=True)
|
617 |
|
|