Spaces:
Runtime error
Runtime error
prabinpanta0
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -60,13 +60,29 @@ def generate(text):
|
|
60 |
except Exception as e:
|
61 |
return str(e)
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
iface = gr.Interface(
|
64 |
fn=generate,
|
65 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
66 |
-
outputs=gr.
|
67 |
title="Chuunibyou Text Generator",
|
68 |
-
description="Transform text into an elaborate and formal style with a nobleman tone."
|
|
|
69 |
)
|
70 |
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
60 |
except Exception as e:
|
61 |
return str(e)
|
62 |
|
63 |
+
# Custom JavaScript for "Copy to Clipboard" functionality
|
64 |
+
custom_js = """
|
65 |
+
function copyToClipboard(textbox_id) {
|
66 |
+
const textbox = document.getElementById(textbox_id);
|
67 |
+
if (textbox) {
|
68 |
+
textbox.select();
|
69 |
+
document.execCommand("copy");
|
70 |
+
}
|
71 |
+
}
|
72 |
+
"""
|
73 |
+
|
74 |
iface = gr.Interface(
|
75 |
fn=generate,
|
76 |
inputs=gr.Textbox(lines=2, placeholder="Enter text here..."),
|
77 |
+
outputs=gr.Textbox(label="Output"),
|
78 |
title="Chuunibyou Text Generator",
|
79 |
+
description="Transform text into an elaborate and formal style with a nobleman tone.",
|
80 |
+
live=True
|
81 |
)
|
82 |
|
83 |
+
iface.launch(components_js=custom_js, additional_buttons=[
|
84 |
+
{
|
85 |
+
"label": "Copy to Clipboard",
|
86 |
+
"onclick": "copyToClipboard('output-textbox')"
|
87 |
+
}
|
88 |
+
])
|