Push Bot commited on
Commit
2b9d4ff
·
1 Parent(s): 67147ac

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
@@ -772,12 +772,8 @@ def debug_compile_output_zip():
772
  )
773
 
774
  try:
775
- b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
776
- open_tab = f"<a target='_blank' rel='noopener' href='data:application/pdf;base64,{b64}'>Open PDF in new tab</a>"
777
- html = (
778
- f"<div style='margin-bottom:8px'>{open_tab}</div>"
779
- + _pdf_to_iframe_html(pdf_path, height="700px")
780
- )
781
  _write_logs(LOG_PATH, logs)
782
  return html
783
  except Exception as e:
@@ -891,12 +887,7 @@ def debug_compile_last_pipeline_zip():
891
  + "</pre>"
892
  )
893
  try:
894
- b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
895
- open_tab = f"<a target='_blank' rel='noopener' href='data:application/pdf;base64,{b64}'>Open PDF in new tab</a>"
896
- html = (
897
- f"<div style='margin-bottom:8px'>{open_tab}</div>"
898
- + _pdf_to_iframe_html(pdf_path, height="700px")
899
- )
900
  _write_logs(LOG_PATH, logs)
901
  return html
902
  except Exception as e:
@@ -999,12 +990,7 @@ def debug_compile_uploaded_zip(zip_file):
999
  + "</pre>"
1000
  )
1001
  try:
1002
- b64 = base64.b64encode(pdf_path.read_bytes()).decode("utf-8")
1003
- open_tab = f"<a target='_blank' rel='noopener' href='data:application/pdf;base64,{b64}'>Open PDF in new tab</a>"
1004
- html = (
1005
- f"<div style='margin-bottom:8px'>{open_tab}</div>"
1006
- + _pdf_to_iframe_html(pdf_path, height="700px")
1007
- )
1008
  _write_logs(LOG_PATH, logs)
1009
  return html
1010
  except Exception as e:
 
772
  )
773
 
774
  try:
775
+ # Use served file path to avoid data: URI issues
776
+ html = _pdf_to_iframe_file(pdf_path, height="700px")
 
 
 
 
777
  _write_logs(LOG_PATH, logs)
778
  return html
779
  except Exception as e:
 
887
  + "</pre>"
888
  )
889
  try:
890
+ html = _pdf_to_iframe_file(pdf_path, height="700px")
 
 
 
 
 
891
  _write_logs(LOG_PATH, logs)
892
  return html
893
  except Exception as e:
 
990
  + "</pre>"
991
  )
992
  try:
993
+ html = _pdf_to_iframe_file(pdf_path, height="700px")
 
 
 
 
 
994
  _write_logs(LOG_PATH, logs)
995
  return html
996
  except Exception as e: