rairo commited on
Commit
f2f2fdc
·
verified ·
1 Parent(s): c09b0a8

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +5 -9
main.py CHANGED
@@ -625,7 +625,6 @@ if not os.path.exists(LOG_FILE_PATH):
625
  pass # create empty file
626
 
627
  logging.basicConfig(filename=LOG_FILE_PATH, level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
628
-
629
  @app.route('/api/download/story_archive/<story_id>', methods=['GET'])
630
  def download_story_archive(story_id):
631
  try:
@@ -636,7 +635,7 @@ def download_story_archive(story_id):
636
  if not auth_header.startswith('Bearer '):
637
  logging.warning("❌ Missing or invalid token")
638
  return jsonify({'error': 'Missing or invalid token'}), 401
639
-
640
  token = auth_header.split(' ')[1]
641
  uid = verify_token(token)
642
  if not uid:
@@ -672,10 +671,7 @@ def download_story_archive(story_id):
672
 
673
  pdf.multi_cell(190, 10, f"Story ID: {story_id}")
674
  pdf.multi_cell(190, 10, f"Title: {title}")
675
- pdf.ln(5)
676
- pdf.multi_cell(190, 10, "Full Story:")
677
- pdf.multi_cell(190, 10, full_text)
678
- pdf.ln(10)
679
 
680
  bucket = storage.bucket()
681
 
@@ -706,8 +702,9 @@ def download_story_archive(story_id):
706
 
707
  blob = bucket.blob(file_path)
708
  blob.download_to_filename(temp_img_path)
709
-
710
- pdf.image(temp_img_path, x=10, w=100)
 
711
  os.unlink(temp_img_path)
712
  logging.info(f"✅ Image embedded in PDF for section {idx + 1}")
713
  except Exception as img_error:
@@ -787,7 +784,6 @@ def download_story_archive(story_id):
787
  traceback.print_exc()
788
  return jsonify({'error': str(e)}), 500
789
 
790
-
791
  def extract_firebase_path(public_url: str) -> str:
792
  """
793
  Attempt to parse a Firebase/Google Storage URL, returning just the
 
625
  pass # create empty file
626
 
627
  logging.basicConfig(filename=LOG_FILE_PATH, level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s")
 
628
  @app.route('/api/download/story_archive/<story_id>', methods=['GET'])
629
  def download_story_archive(story_id):
630
  try:
 
635
  if not auth_header.startswith('Bearer '):
636
  logging.warning("❌ Missing or invalid token")
637
  return jsonify({'error': 'Missing or invalid token'}), 401
638
+
639
  token = auth_header.split(' ')[1]
640
  uid = verify_token(token)
641
  if not uid:
 
671
 
672
  pdf.multi_cell(190, 10, f"Story ID: {story_id}")
673
  pdf.multi_cell(190, 10, f"Title: {title}")
674
+ pdf.ln(10) # Add spacing before sections start
 
 
 
675
 
676
  bucket = storage.bucket()
677
 
 
702
 
703
  blob = bucket.blob(file_path)
704
  blob.download_to_filename(temp_img_path)
705
+
706
+ # Adjust image placement and size to fit allocated space
707
+ pdf.image(temp_img_path, x=10, w=pdf.w - 20, h=100) # Full allocated width, fixed height
708
  os.unlink(temp_img_path)
709
  logging.info(f"✅ Image embedded in PDF for section {idx + 1}")
710
  except Exception as img_error:
 
784
  traceback.print_exc()
785
  return jsonify({'error': str(e)}), 500
786
 
 
787
  def extract_firebase_path(public_url: str) -> str:
788
  """
789
  Attempt to parse a Firebase/Google Storage URL, returning just the