acecalisto3 commited on
Commit
026eb3a
·
verified ·
1 Parent(s): 683321c

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +10 -4
app2.py CHANGED
@@ -5,7 +5,7 @@ import logging
5
  import mimetypes
6
  import time
7
  from PIL import Image
8
- import zxing
9
  import io
10
  import zipfile
11
  import tempfile
@@ -33,6 +33,11 @@ logger = logging.getLogger(__name__)
33
  # Ensure output directories exist
34
  Path('output/qr_codes').mkdir(parents=True, exist_ok=True)
35
 
 
 
 
 
 
36
  class URLProcessor:
37
  def __init__(self):
38
  self.session = requests.Session()
@@ -454,13 +459,14 @@ def datachat_simple(data_input: str, query: str) -> str:
454
  def datachat_interface(mode: str, data_source: str, json_input: str, qr_image: str, query: str) -> str:
455
  """Interface for DataChat functionality"""
456
  data = None
457
- resolution = None # Initialize resolution variable
458
  if data_source == "JSON Input":
459
  data = json_input
460
  elif data_source == "QR Code":
461
  try:
462
- decoded_data, resolution = decode_qr_code(qr_image) # Get both data and resolution
463
  data = decoded_data
 
 
464
  except Exception as e:
465
  return f"Invalid QR code data provided: {e}"
466
  else:
@@ -526,4 +532,4 @@ def main():
526
  )
527
 
528
  if __name__ == "__main__":
529
- main()
 
5
  import mimetypes
6
  import time
7
  from PIL import Image
8
+ from pyzbar.pyzbar import decode
9
  import io
10
  import zipfile
11
  import tempfile
 
33
  # Ensure output directories exist
34
  Path('output/qr_codes').mkdir(parents=True, exist_ok=True)
35
 
36
+ # At the top of the file, remove these imports:
37
+ # from config import Config
38
+ # from proxy_handler import ProxyHandler
39
+ # from robots_handler import RobotsHandler
40
+
41
  class URLProcessor:
42
  def __init__(self):
43
  self.session = requests.Session()
 
459
  def datachat_interface(mode: str, data_source: str, json_input: str, qr_image: str, query: str) -> str:
460
  """Interface for DataChat functionality"""
461
  data = None
 
462
  if data_source == "JSON Input":
463
  data = json_input
464
  elif data_source == "QR Code":
465
  try:
466
+ decoded_data = decode_qr_code(qr_image) # Updated to use new function
467
  data = decoded_data
468
+ if not data:
469
+ return "No QR code found in the provided image."
470
  except Exception as e:
471
  return f"Invalid QR code data provided: {e}"
472
  else:
 
532
  )
533
 
534
  if __name__ == "__main__":
535
+ main()