seawolf2357 commited on
Commit
4fbc4cf
ยท
verified ยท
1 Parent(s): 32279d4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -8
app.py CHANGED
@@ -44,15 +44,11 @@ iframe {
44
  }
45
  """
46
 
47
- # ๊ฒฐ๊ณผ ์ฒ˜๋ฆฌ ํ•จ์ˆ˜ ์ •์˜
48
  def process_result(input_text):
49
- # ์ž…๋ ฅ๋œ ํ…์ŠคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ณ  '์ฝ”๋“œ'๊ฐ€ ํฌํ•จ๋˜๋ฉด ํŠน์ • ์Šคํƒ€์ผ๊ณผ ํ•จ๊ป˜ ์ถœ๋ ฅ
50
- if "์ฝ”๋“œ" in input_text:
51
- return f"""<div class="code-result">{input_text}
52
- <button class="copy-button" onclick="navigator.clipboard.writeText('{input_text.replace("'", "\\'")}');">Copy</button>
53
  </div>"""
54
- else:
55
- return input_text
56
 
57
  def app():
58
  with gr.Blocks(css=css_style) as demo:
@@ -66,7 +62,6 @@ def app():
66
  gr.Markdown("### ์›น์„œ๋น„์Šค ๋™์ž‘ ํ™”๋ฉด", elem_id="title-2")
67
  gr.HTML(value='<iframe src="https://seawolf2357-frametest1.hf.space"></iframe>')
68
 
69
- # ์‚ฌ์šฉ์ž ์ž…๋ ฅ ๋ฐ ๊ฒฐ๊ณผ ์ถœ๋ ฅ
70
  input_text = gr.Textbox(label="์—ฌ๊ธฐ์— ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”")
71
  result = gr.HTML(label="๊ฒฐ๊ณผ", live=True)
72
  input_text.change(fn=process_result, inputs=input_text, outputs=result)
 
44
  }
45
  """
46
 
 
47
  def process_result(input_text):
48
+ # HTML ์—”ํ‹ฐํ‹ฐ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ , 'data-text' ์†์„ฑ์„ ํ†ตํ•ด ํด๋ฆฝ๋ณด๋“œ ๋ณต์‚ฌ ๊ธฐ๋Šฅ ๊ตฌํ˜„
49
+ return f"""<div class="code-result">{input_text}
50
+ <button class="copy-button" data-text="{input_text}" onclick="navigator.clipboard.writeText(this.getAttribute('data-text'));">Copy</button>
 
51
  </div>"""
 
 
52
 
53
  def app():
54
  with gr.Blocks(css=css_style) as demo:
 
62
  gr.Markdown("### ์›น์„œ๋น„์Šค ๋™์ž‘ ํ™”๋ฉด", elem_id="title-2")
63
  gr.HTML(value='<iframe src="https://seawolf2357-frametest1.hf.space"></iframe>')
64
 
 
65
  input_text = gr.Textbox(label="์—ฌ๊ธฐ์— ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”")
66
  result = gr.HTML(label="๊ฒฐ๊ณผ", live=True)
67
  input_text.change(fn=process_result, inputs=input_text, outputs=result)