Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,6 +4,7 @@ from PIL import Image
|
|
| 4 |
import gradio as gr
|
| 5 |
import tempfile
|
| 6 |
import numpy as np
|
|
|
|
| 7 |
|
| 8 |
# Function to generate a QR code
|
| 9 |
def generate_qr(data):
|
|
@@ -43,8 +44,8 @@ def read_qr(img):
|
|
| 43 |
def create_gradio_interface():
|
| 44 |
# QR Code Generator with Display and Downloadable Link
|
| 45 |
def generate_qr_interface(data):
|
| 46 |
-
|
| 47 |
-
return qr_image
|
| 48 |
|
| 49 |
# QR Code Reader with Copy-to-Clipboard Button
|
| 50 |
def read_qr_interface(img):
|
|
@@ -55,7 +56,7 @@ def create_gradio_interface():
|
|
| 55 |
generate_interface = gr.Interface(
|
| 56 |
fn=generate_qr_interface,
|
| 57 |
inputs=gr.Textbox(placeholder="Enter text or URL here...", label="Data to Encode"),
|
| 58 |
-
outputs=
|
| 59 |
title="Generate QR Code",
|
| 60 |
description="Quickly create a QR code from any text or URL.",
|
| 61 |
)
|
|
@@ -81,8 +82,8 @@ def create_gradio_interface():
|
|
| 81 |
copy_button.click(
|
| 82 |
None,
|
| 83 |
qr_text,
|
| 84 |
-
|
| 85 |
-
|
| 86 |
)
|
| 87 |
|
| 88 |
demo.launch(share=True)
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
import tempfile
|
| 6 |
import numpy as np
|
| 7 |
+
import os
|
| 8 |
|
| 9 |
# Function to generate a QR code
|
| 10 |
def generate_qr(data):
|
|
|
|
| 44 |
def create_gradio_interface():
|
| 45 |
# QR Code Generator with Display and Downloadable Link
|
| 46 |
def generate_qr_interface(data):
|
| 47 |
+
_, qr_image = generate_qr(data) # Only need the PIL image
|
| 48 |
+
return qr_image # Show image
|
| 49 |
|
| 50 |
# QR Code Reader with Copy-to-Clipboard Button
|
| 51 |
def read_qr_interface(img):
|
|
|
|
| 56 |
generate_interface = gr.Interface(
|
| 57 |
fn=generate_qr_interface,
|
| 58 |
inputs=gr.Textbox(placeholder="Enter text or URL here...", label="Data to Encode"),
|
| 59 |
+
outputs=gr.Image(label="Generated QR Code"), # Only show the image
|
| 60 |
title="Generate QR Code",
|
| 61 |
description="Quickly create a QR code from any text or URL.",
|
| 62 |
)
|
|
|
|
| 82 |
copy_button.click(
|
| 83 |
None,
|
| 84 |
qr_text,
|
| 85 |
+
None,
|
| 86 |
+
_js="() => {navigator.clipboard.writeText(document.querySelector('input[type=text]').value); return 'Copied to Clipboard!'}"
|
| 87 |
)
|
| 88 |
|
| 89 |
demo.launch(share=True)
|