prabinpanta0 commited on
Commit
60ea12e
·
verified ·
1 Parent(s): b6037de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
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.Text()
67
  title="Chuunibyou Text Generator",
68
- description="Transform text into an elaborate and formal style with a nobleman tone."
 
69
  )
70
 
71
- if __name__ == "__main__":
72
- iface.launch()
 
 
 
 
 
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
+ ])