ginipick commited on
Commit
ba82085
Β·
verified Β·
1 Parent(s): 82e2b16

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -14
app.py CHANGED
@@ -1,7 +1,7 @@
1
  #!/usr/bin/env python3
2
  # -*- coding: utf-8 -*-
3
  """
4
- 3D Flipbook Viewer (Gradio) – 전체 μ†ŒμŠ€ (μˆ˜μ • 버전)
5
  μ΅œμ’… μˆ˜μ •: 2025-05-18
6
  """
7
 
@@ -198,6 +198,7 @@ def generate_flipbook_html(
198
  html_file = f"flipbook_{session_id}.html"
199
  html_path = os.path.join(HTML_DIR, html_file)
200
 
 
201
  html = f"""
202
  <!DOCTYPE html>
203
  <html lang="ko">
@@ -230,9 +231,13 @@ def generate_flipbook_html(
230
  </div>
231
 
232
  <script>
233
- document.addEventListener('DOMContentLoaded',()=>{
234
- const hide=()=>{{document.getElementById('loading').style.display='none'}};
235
- try{{
 
 
 
 
236
  const options = {{
237
  pages: {pages_json},
238
  viewMode: "{view_mode}",
@@ -242,13 +247,13 @@ document.addEventListener('DOMContentLoaded',()=>{
242
  singlePageModeIfMobile: true,
243
  pageFlipDuration: 1,
244
  thumbnailsOnStart: true,
245
- btnThumbs: {{enabled:true}},
246
- btnPrint: {{enabled:true}},
247
- btnDownloadPages: {{enabled:true}},
248
- btnDownloadPdf: {{enabled:true}},
249
- btnShare: {{enabled:true}},
250
- btnSound: {{enabled:true}},
251
- btnExpand: {{enabled:true}}
252
  }};
253
  new FlipBook(document.getElementById('flipbook-container'), options);
254
  setTimeout(hide, 1000);
@@ -256,17 +261,15 @@ document.addEventListener('DOMContentLoaded',()=>{
256
  console.error(e);
257
  alert('ν”Œλ¦½λΆ μ΄ˆκΈ°ν™” 였λ₯˜:' + e.message);
258
  }}
259
- });
260
  </script>
261
  </body>
262
  </html>
263
  """
264
 
265
  Path(html_path).write_text(html, encoding="utf-8")
266
-
267
  public_url = f"/public/flipbooks/{html_file}"
268
 
269
- # μ‚¬μš©μžμ—κ²Œ λŒλ €μ€„ λ²„νŠΌ ν˜•νƒœ 링크
270
  return f"""
271
  <div style="text-align:center;padding:20px;background:#f9f9f9;border-radius:5px">
272
  <h2 style="margin:0;color:#333">ν”Œλ¦½λΆμ΄ μ€€λΉ„λ˜μ—ˆμŠ΅λ‹ˆλ‹€!</h2>
 
1
  #!/usr/bin/env python3
2
  # -*- coding: utf-8 -*-
3
  """
4
+ 3D Flipbook Viewer (Gradio) – 전체 μ†ŒμŠ€ (SyntaxError μˆ˜μ • 버전)
5
  μ΅œμ’… μˆ˜μ •: 2025-05-18
6
  """
7
 
 
198
  html_file = f"flipbook_{session_id}.html"
199
  html_path = os.path.join(HTML_DIR, html_file)
200
 
201
+ # f-string λ‚΄λΆ€μ—μ„œ JS용 { }λ₯Ό ν‘œν˜„ν•˜λ €λ©΄ {{ }} 둜 써야 함
202
  html = f"""
203
  <!DOCTYPE html>
204
  <html lang="ko">
 
231
  </div>
232
 
233
  <script>
234
+ document.addEventListener('DOMContentLoaded', () => {{
235
+ // hide() ν•¨μˆ˜: λ‘œλ”© λ©”μ‹œμ§€ 제거
236
+ const hide = () => {{
237
+ document.getElementById('loading').style.display = 'none';
238
+ }};
239
+
240
+ try {{
241
  const options = {{
242
  pages: {pages_json},
243
  viewMode: "{view_mode}",
 
247
  singlePageModeIfMobile: true,
248
  pageFlipDuration: 1,
249
  thumbnailsOnStart: true,
250
+ btnThumbs: {{ enabled: true }},
251
+ btnPrint: {{ enabled: true }},
252
+ btnDownloadPages: {{ enabled: true }},
253
+ btnDownloadPdf: {{ enabled: true }},
254
+ btnShare: {{ enabled: true }},
255
+ btnSound: {{ enabled: true }},
256
+ btnExpand: {{ enabled: true }}
257
  }};
258
  new FlipBook(document.getElementById('flipbook-container'), options);
259
  setTimeout(hide, 1000);
 
261
  console.error(e);
262
  alert('ν”Œλ¦½λΆ μ΄ˆκΈ°ν™” 였λ₯˜:' + e.message);
263
  }}
264
+ }});
265
  </script>
266
  </body>
267
  </html>
268
  """
269
 
270
  Path(html_path).write_text(html, encoding="utf-8")
 
271
  public_url = f"/public/flipbooks/{html_file}"
272
 
 
273
  return f"""
274
  <div style="text-align:center;padding:20px;background:#f9f9f9;border-radius:5px">
275
  <h2 style="margin:0;color:#333">ν”Œλ¦½λΆμ΄ μ€€λΉ„λ˜μ—ˆμŠ΅λ‹ˆλ‹€!</h2>