seawolf2357 commited on
Commit
8e86d61
ยท
verified ยท
1 Parent(s): 4fbc4cf

Update app.py

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