Spaces:
Paused
Paused
| import gradio as gr | |
| import os | |
| # CSS ์คํ์ผ ์ ์ | |
| css_style = """ | |
| footer { | |
| visibility: hidden; | |
| } | |
| body { | |
| font-family: Arial, sans-serif; | |
| background-color: #f0f0f9; | |
| } | |
| h4 { | |
| color: #333; | |
| } | |
| iframe { | |
| border: 2px solid #007bff; | |
| border-radius: 8px; | |
| width: 100%; | |
| height: 700px; | |
| } | |
| .gr-column { | |
| padding: 10px; | |
| width: 100%; /* ์ ์ฒด ๋๋น ์ฌ์ฉ */ | |
| max-width: 1200px; /* ์ต๋ ๋๋น ์ค์ */ | |
| margin: 0 auto; /* ๊ฐ์ด๋ฐ ์ ๋ ฌ */ | |
| } | |
| /* '์ฝ๋' ํฌํจ ๊ฒฐ๊ณผ์ ๋ํ ์คํ์ผ */ | |
| .code-result { | |
| background-color: black; | |
| color: white; | |
| padding: 10px; | |
| border-radius: 8px; | |
| position: relative; | |
| font-size: 2em; /* ํฐํธ ํฌ๊ธฐ 2๋ฐฐ ์ฆ๊ฐ */ | |
| } | |
| /* Copy ๋ฒํผ ์คํ์ผ */ | |
| .copy-button { | |
| position: absolute; | |
| top: 10px; | |
| right: 10px; | |
| padding: 5px 10px; | |
| border: none; | |
| border-radius: 5px; | |
| cursor: pointer; | |
| background-color: #007bff; | |
| color: white; | |
| } | |
| """ | |
| # ํ๊ฒฝ ๋ณ์์์ URL ๋ถ๋ฌ์ค๊ธฐ | |
| cburl = "https://www.chatbase.co/chatbot-iframe/100-daum-net-eurma-q2o" | |
| # ์ ๋ ฅ๋ ํ ์คํธ๋ฅผ ์ฒ๋ฆฌํ๋ ํจ์ | |
| def process_result(input_text): | |
| # HTML์ ๋ฐํํ๋ ๋ก์ง. '์ฝ๋' ํฌํจ ์ฌ๋ถ์ ๋ฐ๋ผ ๋ค๋ฅธ ๊ฒฐ๊ณผ ๋ฐํ | |
| if "์ฝ๋" in input_text: | |
| return f"""<div class="code-result">{input_text} | |
| <button class="copy-button" data-text="{input_text}" onclick="navigator.clipboard.writeText(this.getAttribute('data-text'));">Copy</button> | |
| </div>""" | |
| else: | |
| return input_text | |
| def app(): | |
| with gr.Blocks(css=css_style) as demo: | |
| with gr.Row(): | |
| # ๋น๋ฐ URL ์ฌ์ฉ | |
| gr.HTML(value=f'<iframe src="{cburl}"></iframe>') | |
| # ์ ๋ ฅ ํ๋์ ๊ฒฐ๊ณผ ์ถ๋ ฅ ์ค์ | |
| input_text = gr.Textbox(label="๋ฉ๋ชจ", placeholder="๋ฉ๋ชจ๋ฅผ ์ฌ๊ธฐ์ ์ ๋ ฅํ์ธ์") # ๋ ์ด๋ธ ๋ณ๊ฒฝ | |
| result = gr.HTML() | |
| input_text.change(fn=process_result, inputs=[input_text], outputs=[result]) | |
| return demo | |
| demo = app() | |
| demo.launch(auth=("arxiv", "gpt")) |