Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -28,29 +28,34 @@ iframe {
|
|
| 28 |
color: white;
|
| 29 |
padding: 10px;
|
| 30 |
border-radius: 8px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
}
|
| 32 |
"""
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
copyButton.onclick = function() {
|
| 44 |
-
navigator.clipboard.writeText(result.innerText);
|
| 45 |
-
};
|
| 46 |
-
result.appendChild(copyButton);
|
| 47 |
-
}
|
| 48 |
-
});
|
| 49 |
-
});
|
| 50 |
-
"""
|
| 51 |
|
| 52 |
def app():
|
| 53 |
-
with gr.Blocks(css=css_style
|
| 54 |
gr.Markdown("# AIQ Codepilot TEST", elem_id="main-title")
|
| 55 |
with gr.Row():
|
| 56 |
with gr.Column():
|
|
@@ -60,6 +65,11 @@ def app():
|
|
| 60 |
with gr.Column():
|
| 61 |
gr.Markdown("### 웹서비스 동작 화면", elem_id="title-2")
|
| 62 |
gr.HTML(value='<iframe src="https://seawolf2357-frametest1.hf.space"></iframe>')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
return demo
|
| 65 |
|
|
|
|
| 28 |
color: white;
|
| 29 |
padding: 10px;
|
| 30 |
border-radius: 8px;
|
| 31 |
+
position: relative;
|
| 32 |
+
}
|
| 33 |
+
/* Copy 버튼 스타일 */
|
| 34 |
+
.copy-button {
|
| 35 |
+
position: absolute;
|
| 36 |
+
top: 10px;
|
| 37 |
+
right: 10px;
|
| 38 |
+
padding: 5px 10px;
|
| 39 |
+
border: none;
|
| 40 |
+
border-radius: 5px;
|
| 41 |
+
cursor: pointer;
|
| 42 |
+
background-color: #007bff;
|
| 43 |
+
color: white;
|
| 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:
|
| 59 |
gr.Markdown("# AIQ Codepilot TEST", elem_id="main-title")
|
| 60 |
with gr.Row():
|
| 61 |
with gr.Column():
|
|
|
|
| 65 |
with gr.Column():
|
| 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)
|
| 73 |
|
| 74 |
return demo
|
| 75 |
|