acecalisto3 commited on
Commit
7a33aae
·
verified ·
1 Parent(s): bdf9472

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +7 -10
app2.py CHANGED
@@ -6,7 +6,6 @@ import mimetypes
6
  import time
7
  from PIL import Image
8
  import zxing
9
- import random
10
  import io
11
  import zipfile
12
  import tempfile
@@ -537,12 +536,12 @@ class FileProcessor:
537
  logger.error(f"Unexpected error while cleaning JSON: {e}")
538
  return None
539
 
540
- def generate_qr(json_data):
541
- data = FileProcessor.clean_json(json_data)
542
- if data:
543
- return FileProcessor.generate_qr_code(data)
544
- return None
545
-
546
  if combined:
547
  cleaned_data = clean_json(data)
548
  if cleaned_data:
@@ -955,8 +954,6 @@ def create_interface():
955
  def main():
956
  mimetypes.init()
957
  Path('output/qr_codes').mkdir(parents=True, exist_ok=True)
958
-
959
- # Create and launch the interface
960
  interface = create_interface()
961
  interface.launch(
962
  server_name="0.0.0.0",
@@ -968,4 +965,4 @@ def main():
968
  )
969
 
970
  if __name__ == "__main__":
971
- main()
 
6
  import time
7
  from PIL import Image
8
  import zxing
 
9
  import io
10
  import zipfile
11
  import tempfile
 
536
  logger.error(f"Unexpected error while cleaning JSON: {e}")
537
  return None
538
 
539
+ def generate_qr_code(data: Union[str, Dict], combined: bool = True) -> List[str]:
540
+ """Generate QR code(s) from data"""
541
+ try:
542
+ output_dir = Path('output/qr_codes')
543
+ output_dir.mkdir(parents=True, exist_ok=True)
544
+
545
  if combined:
546
  cleaned_data = clean_json(data)
547
  if cleaned_data:
 
954
  def main():
955
  mimetypes.init()
956
  Path('output/qr_codes').mkdir(parents=True, exist_ok=True)
 
 
957
  interface = create_interface()
958
  interface.launch(
959
  server_name="0.0.0.0",
 
965
  )
966
 
967
  if __name__ == "__main__":
968
+ main()