Spaces:
Sleeping
Sleeping
Add application file
Browse files- app.py +19 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import qrcode
|
3 |
+
import re
|
4 |
+
|
5 |
+
def generate_qr(url):
|
6 |
+
if not re.match(r'^https?://', url):
|
7 |
+
raise gr.Error("Input must be a valid URL")
|
8 |
+
|
9 |
+
qr = qrcode.make(url)
|
10 |
+
return qr.get_image()
|
11 |
+
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=generate_qr,
|
14 |
+
inputs=gr.Textbox(label="URL"),
|
15 |
+
outputs="image",
|
16 |
+
allow_flagging="never"
|
17 |
+
)
|
18 |
+
|
19 |
+
iface.launch(debug=True)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
qrcode
|