Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -32,6 +32,7 @@ api_key = os.environ['Gemini']
|
|
| 32 |
FIREBASE_API_KEY = os.environ.get('FIREBASE_API_KEY')
|
| 33 |
|
| 34 |
|
|
|
|
| 35 |
# Helper functions
|
| 36 |
def configure_gemini():
|
| 37 |
genai.configure(api_key=api_key)
|
|
@@ -422,6 +423,8 @@ def get_blob_from_image_url(image_url):
|
|
| 422 |
return blob_path
|
| 423 |
return None
|
| 424 |
|
|
|
|
|
|
|
| 425 |
@app.route('/api/admin/receipt/<string:transaction_id>/view', methods=['GET'])
|
| 426 |
def view_receipt(transaction_id):
|
| 427 |
try:
|
|
@@ -439,9 +442,9 @@ def view_receipt(transaction_id):
|
|
| 439 |
if not blob_path:
|
| 440 |
return jsonify({'error': 'Could not determine blob path from URL'}), 500
|
| 441 |
|
| 442 |
-
print(f"Blob path
|
| 443 |
-
|
| 444 |
blob = bucket.blob(blob_path)
|
|
|
|
| 445 |
if not blob.exists():
|
| 446 |
print("Blob does not exist at path:", blob_path)
|
| 447 |
return jsonify({'error': 'Blob not found'}), 404
|
|
@@ -471,11 +474,12 @@ def download_receipt(transaction_id):
|
|
| 471 |
if not image_url:
|
| 472 |
return jsonify({'error': 'No receipt image found for this transaction'}), 404
|
| 473 |
|
| 474 |
-
|
| 475 |
if not blob_path:
|
| 476 |
return jsonify({'error': 'Could not determine blob path from URL'}), 500
|
| 477 |
|
| 478 |
-
print(f"Blob path
|
|
|
|
| 479 |
|
| 480 |
blob = bucket.blob(blob_path)
|
| 481 |
if not blob.exists():
|
|
|
|
| 32 |
FIREBASE_API_KEY = os.environ.get('FIREBASE_API_KEY')
|
| 33 |
|
| 34 |
|
| 35 |
+
|
| 36 |
# Helper functions
|
| 37 |
def configure_gemini():
|
| 38 |
genai.configure(api_key=api_key)
|
|
|
|
| 423 |
return blob_path
|
| 424 |
return None
|
| 425 |
|
| 426 |
+
|
| 427 |
+
|
| 428 |
@app.route('/api/admin/receipt/<string:transaction_id>/view', methods=['GET'])
|
| 429 |
def view_receipt(transaction_id):
|
| 430 |
try:
|
|
|
|
| 442 |
if not blob_path:
|
| 443 |
return jsonify({'error': 'Could not determine blob path from URL'}), 500
|
| 444 |
|
| 445 |
+
print(f"**DEBUG: Blob path being used: {blob_path}**") # ADD THIS LINE
|
|
|
|
| 446 |
blob = bucket.blob(blob_path)
|
| 447 |
+
|
| 448 |
if not blob.exists():
|
| 449 |
print("Blob does not exist at path:", blob_path)
|
| 450 |
return jsonify({'error': 'Blob not found'}), 404
|
|
|
|
| 474 |
if not image_url:
|
| 475 |
return jsonify({'error': 'No receipt image found for this transaction'}), 404
|
| 476 |
|
| 477 |
+
blob_path = get_blob_from_image_url(image_url)
|
| 478 |
if not blob_path:
|
| 479 |
return jsonify({'error': 'Could not determine blob path from URL'}), 500
|
| 480 |
|
| 481 |
+
print(f"**DEBUG: Blob path being used: {blob_path}**") # ADD THIS LINE
|
| 482 |
+
blob = bucket.blob(blob_path) # Debug log
|
| 483 |
|
| 484 |
blob = bucket.blob(blob_path)
|
| 485 |
if not blob.exists():
|