Deniel Dimitrov commited on
Commit
202b173
·
1 Parent(s): 426eb65

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -41,9 +41,15 @@ iface = gr.Interface(
41
  fn=convert_to_ascii, # Function to run
42
  inputs=["image","number"], # Input component (in this case, an image)
43
  outputs="text", # Output component (in this case, text)
44
- title="image-to-ascii (by peasoup)", # Title for the interface
45
- clipboard=True # Add clipboard option for output text
46
  )
47
 
 
 
 
 
 
 
 
48
  # Launch the interface
49
  iface.launch()
 
41
  fn=convert_to_ascii, # Function to run
42
  inputs=["image","number"], # Input component (in this case, an image)
43
  outputs="text", # Output component (in this case, text)
44
+ title="image-to-ascii (by peasoup)"
 
45
  )
46
 
47
+ # Function to generate HTML code for the output text with a copy button
48
+ def copy_button(output_text):
49
+ return f"{output_text}<br><br><button onclick=\"navigator.clipboard.writeText('{output_text}').then(() => {{alert('Text copied to clipboard')}})\">Copy to Clipboard</button>"
50
+
51
+ # Set custom post-processing for the output text
52
+ iface.test_command = lambda output_text: copy_button(output_text)
53
+
54
  # Launch the interface
55
  iface.launch()