Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -34,11 +34,9 @@ def scan_qr_send_form(image, lat, lng):
|
|
| 34 |
else:
|
| 35 |
return "❌ No QR code detected"
|
| 36 |
|
| 37 |
-
# ===== Gradio UI =====
|
| 38 |
with gr.Blocks() as demo:
|
| 39 |
gr.Markdown("### Scan QR Code & Auto GPS Location → Google Form")
|
| 40 |
|
| 41 |
-
# แก้ไขจาก webcam → upload image
|
| 42 |
qr_image = gr.Image(type="pil", label="Upload QR Code Image")
|
| 43 |
|
| 44 |
lat_input = gr.Textbox(label="Latitude", interactive=False)
|
|
@@ -51,10 +49,9 @@ with gr.Blocks() as demo:
|
|
| 51 |
inputs=[qr_image, lat_input, lng_input],
|
| 52 |
outputs=output
|
| 53 |
)
|
| 54 |
-
|
| 55 |
-
# JS
|
| 56 |
-
|
| 57 |
-
"""
|
| 58 |
<script>
|
| 59 |
if (navigator.geolocation) {
|
| 60 |
navigator.geolocation.getCurrentPosition(function(position) {
|
|
@@ -65,7 +62,6 @@ with gr.Blocks() as demo:
|
|
| 65 |
alert("Geolocation is not supported by this browser.");
|
| 66 |
}
|
| 67 |
</script>
|
| 68 |
-
|
| 69 |
-
)
|
| 70 |
|
| 71 |
demo.launch()
|
|
|
|
| 34 |
else:
|
| 35 |
return "❌ No QR code detected"
|
| 36 |
|
|
|
|
| 37 |
with gr.Blocks() as demo:
|
| 38 |
gr.Markdown("### Scan QR Code & Auto GPS Location → Google Form")
|
| 39 |
|
|
|
|
| 40 |
qr_image = gr.Image(type="pil", label="Upload QR Code Image")
|
| 41 |
|
| 42 |
lat_input = gr.Textbox(label="Latitude", interactive=False)
|
|
|
|
| 49 |
inputs=[qr_image, lat_input, lng_input],
|
| 50 |
outputs=output
|
| 51 |
)
|
| 52 |
+
|
| 53 |
+
# แทรก JS ผ่าน HTML component
|
| 54 |
+
gr.HTML("""
|
|
|
|
| 55 |
<script>
|
| 56 |
if (navigator.geolocation) {
|
| 57 |
navigator.geolocation.getCurrentPosition(function(position) {
|
|
|
|
| 62 |
alert("Geolocation is not supported by this browser.");
|
| 63 |
}
|
| 64 |
</script>
|
| 65 |
+
""")
|
|
|
|
| 66 |
|
| 67 |
demo.launch()
|