Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -502,45 +502,46 @@ with gr.Blocks() as app:
|
|
| 502 |
</div>
|
| 503 |
"""
|
| 504 |
)
|
| 505 |
-
# [์ฌ์ฉ๋ฐฉ๋ฒ
|
| 506 |
sample_btn = gr.Button("์ํ ๋ฃ์ด๋ณด๊ธฐ", elem_id="sample_btn")
|
| 507 |
gr.HTML(
|
| 508 |
"""
|
| 509 |
<script>
|
| 510 |
-
document.
|
| 511 |
-
|
| 512 |
-
|
| 513 |
-
.
|
| 514 |
-
|
| 515 |
-
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
|
| 519 |
-
|
| 520 |
-
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
if(
|
| 524 |
-
|
| 525 |
-
console.log("์ ์ฒด ํ์ด์ง HTML ์
๋ ฅ ํ๋์ ๋ด์ฉ ์ฑ์์ง");
|
| 526 |
} else {
|
| 527 |
-
console.error("
|
| 528 |
}
|
| 529 |
-
}
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
.catch(err => {
|
| 534 |
-
console.error("sample.txt ๋ก๋ ์คํจ", err);
|
| 535 |
});
|
|
|
|
|
|
|
|
|
|
| 536 |
});
|
| 537 |
</script>
|
| 538 |
"""
|
| 539 |
)
|
|
|
|
| 540 |
with gr.Tab("HTML ํ์ฑ ๋ฐ ์น์
์ ํ"):
|
| 541 |
with gr.Row():
|
| 542 |
with gr.Column():
|
| 543 |
-
html_input = gr.Textbox(label="์ ์ฒด ํ์ด์ง HTML ์
๋ ฅ", lines=20, placeholder="HTML ์ฝ๋๋ฅผ ์
๋ ฅํ์ธ์..."
|
| 544 |
parse_btn = gr.Button("Submit")
|
| 545 |
with gr.Column():
|
| 546 |
subject_out = gr.Textbox(label="๊ณผ๋ชฉ๋ช
", interactive=False)
|
|
|
|
| 502 |
</div>
|
| 503 |
"""
|
| 504 |
)
|
| 505 |
+
# ------------------ [์ถ๊ฐ: ์ฌ์ฉ๋ฐฉ๋ฒ ์์ญ ์๋ "์ํ ๋ฃ์ด๋ณด๊ธฐ" ๋ฒํผ ์ถ๊ฐ] ------------------
|
| 506 |
sample_btn = gr.Button("์ํ ๋ฃ์ด๋ณด๊ธฐ", elem_id="sample_btn")
|
| 507 |
gr.HTML(
|
| 508 |
"""
|
| 509 |
<script>
|
| 510 |
+
document.addEventListener("DOMContentLoaded", function(){
|
| 511 |
+
const sampleBtn = document.getElementById("sample_btn");
|
| 512 |
+
if(sampleBtn){
|
| 513 |
+
sampleBtn.addEventListener("click", function(){
|
| 514 |
+
fetch("sample.html")
|
| 515 |
+
.then(response => response.text())
|
| 516 |
+
.then(function(text){
|
| 517 |
+
navigator.clipboard.writeText(text).then(function(){
|
| 518 |
+
console.log("์ํ HTML ๋ณต์ฌ ์ฑ๊ณต");
|
| 519 |
+
}, function(err){
|
| 520 |
+
console.error("ํด๋ฆฝ๋ณด๋ ๋ณต์ฌ ์คํจ:", err);
|
| 521 |
+
});
|
| 522 |
+
var htmlInput = document.querySelector('textarea[aria-label="์ ์ฒด ํ์ด์ง HTML ์
๋ ฅ"]');
|
| 523 |
+
if(htmlInput){
|
| 524 |
+
htmlInput.value = text;
|
|
|
|
| 525 |
} else {
|
| 526 |
+
console.error("์ ์ฒด ํ์ด์ง HTML ์
๋ ฅ ์ฐฝ์ ์ฐพ์ ์ ์์ต๋๋ค.");
|
| 527 |
}
|
| 528 |
+
})
|
| 529 |
+
.catch(function(error){
|
| 530 |
+
console.error("sample.html ๋ถ๋ฌ์ค๊ธฐ ์คํจ:", error);
|
| 531 |
+
});
|
|
|
|
|
|
|
| 532 |
});
|
| 533 |
+
} else {
|
| 534 |
+
console.error("์ํ ๋ฃ์ด๋ณด๊ธฐ ๋ฒํผ์ ์ฐพ์ ์ ์์ต๋๋ค.");
|
| 535 |
+
}
|
| 536 |
});
|
| 537 |
</script>
|
| 538 |
"""
|
| 539 |
)
|
| 540 |
+
# ----------------------------------------------------------------------------------------
|
| 541 |
with gr.Tab("HTML ํ์ฑ ๋ฐ ์น์
์ ํ"):
|
| 542 |
with gr.Row():
|
| 543 |
with gr.Column():
|
| 544 |
+
html_input = gr.Textbox(label="์ ์ฒด ํ์ด์ง HTML ์
๋ ฅ", lines=20, placeholder="HTML ์ฝ๋๋ฅผ ์
๋ ฅํ์ธ์...")
|
| 545 |
parse_btn = gr.Button("Submit")
|
| 546 |
with gr.Column():
|
| 547 |
subject_out = gr.Textbox(label="๊ณผ๋ชฉ๋ช
", interactive=False)
|