opencodeai / app.py
fantos's picture
Update app.py
00ea6e2 verified
raw
history blame
2.06 kB
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"))