Push Bot commited on
Commit
e95db4e
·
1 Parent(s): ecac45b

Debug preview: use served-file iframe instead of data: base64 for all debug views

Browse files
Files changed (1) hide show
  1. app.py +4 -18
app.py CHANGED
@@ -732,12 +732,8 @@ def debug_compile_output_zip():
732
  )
733
 
734
  try:
735
- b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
736
- open_tab = f"<a target='_blank' rel='noopener' href='data:application/pdf;base64,{b64}'>Open PDF in new tab</a>"
737
- html = (
738
- f"<div style='margin-bottom:8px'>{open_tab}</div>"
739
- + _pdf_to_iframe_html(pdf_path, height="700px")
740
- )
741
  _write_logs(LOG_PATH, logs)
742
  return html
743
  except Exception as e:
@@ -851,12 +847,7 @@ def debug_compile_last_pipeline_zip():
851
  + "</pre>"
852
  )
853
  try:
854
- b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
855
- open_tab = f"<a target='_blank' rel='noopener' href='data:application/pdf;base64,{b64}'>Open PDF in new tab</a>"
856
- html = (
857
- f"<div style='margin-bottom:8px'>{open_tab}</div>"
858
- + _pdf_to_iframe_html(pdf_path, height="700px")
859
- )
860
  _write_logs(LOG_PATH, logs)
861
  return html
862
  except Exception as e:
@@ -959,12 +950,7 @@ def debug_compile_uploaded_zip(zip_file):
959
  + "</pre>"
960
  )
961
  try:
962
- b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
963
- open_tab = f"<a target='_blank' rel='noopener' href='data:application/pdf;base64,{b64}'>Open PDF in new tab</a>"
964
- html = (
965
- f"<div style='margin-bottom:8px'>{open_tab}</div>"
966
- + _pdf_to_iframe_html(pdf_path, height="700px")
967
- )
968
  _write_logs(LOG_PATH, logs)
969
  return html
970
  except Exception as e:
 
732
  )
733
 
734
  try:
735
+ # Use served file path to avoid data: URI issues
736
+ html = _pdf_to_iframe_file(pdf_path, height="700px")
 
 
 
 
737
  _write_logs(LOG_PATH, logs)
738
  return html
739
  except Exception as e:
 
847
  + "</pre>"
848
  )
849
  try:
850
+ html = _pdf_to_iframe_file(pdf_path, height="700px")
 
 
 
 
 
851
  _write_logs(LOG_PATH, logs)
852
  return html
853
  except Exception as e:
 
950
  + "</pre>"
951
  )
952
  try:
953
+ html = _pdf_to_iframe_file(pdf_path, height="700px")
 
 
 
 
 
954
  _write_logs(LOG_PATH, logs)
955
  return html
956
  except Exception as e: