71 lines
2.7 KiB
Python
71 lines
2.7 KiB
Python
import requests
|
|
import json
|
|
import time
|
|
|
|
def debug_ocr_timeout():
|
|
print("🔍 Debugging OCR Processing Timeout")
|
|
print("=" * 50)
|
|
|
|
# Login first
|
|
login_data = {'username': 'jleu3482', 'password': 'jleu1212'}
|
|
login_response = requests.post('http://localhost:3015/login', json=login_data)
|
|
print(f'Login status: {login_response.status_code}')
|
|
|
|
if login_response.status_code != 200:
|
|
print("❌ Login failed")
|
|
return False
|
|
|
|
print("✅ Login successful")
|
|
|
|
# Clear all documents first
|
|
print("\n🗑️ Clearing all documents...")
|
|
clear_response = requests.delete('http://localhost:3015/documents')
|
|
print(f'Clear documents status: {clear_response.status_code}')
|
|
|
|
# Check current status after clear
|
|
docs_response = requests.get('http://localhost:3015/documents')
|
|
if docs_response.status_code == 200:
|
|
docs_data = docs_response.json()
|
|
print(f'After clear - Completed: {docs_data.get("completed", 0)}, Processing: {docs_data.get("processing", 0)}, Failed: {docs_data.get("failed", 0)}')
|
|
|
|
# Upload OCR PDF
|
|
print("\n📤 Uploading OCR PDF...")
|
|
with open('ocr.pdf', 'rb') as f:
|
|
files = {'file': ('ocr.pdf', f, 'application/pdf')}
|
|
upload_response = requests.post('http://localhost:3015/documents/upload', files=files)
|
|
|
|
print(f'Upload status: {upload_response.status_code}')
|
|
|
|
if upload_response.status_code == 200:
|
|
print("✅ Upload successful")
|
|
|
|
# Monitor processing status
|
|
print("\n⏳ Monitoring processing status...")
|
|
for i in range(36): # 3 minutes max
|
|
time.sleep(5)
|
|
docs_response = requests.get('http://localhost:3015/documents')
|
|
if docs_response.status_code == 200:
|
|
docs_data = docs_response.json()
|
|
completed = docs_data.get("completed", 0)
|
|
processing = docs_data.get("processing", 0)
|
|
failed = docs_data.get("failed", 0)
|
|
|
|
print(f'Progress - Completed: {completed}, Processing: {processing}, Failed: {failed} ({(i+1)*5}s)')
|
|
|
|
if completed > 0:
|
|
print("🎉 Document processing completed!")
|
|
return True
|
|
elif failed > 0:
|
|
print("❌ Document processing failed")
|
|
return False
|
|
else:
|
|
print(f"❌ Failed to get document status: {docs_response.status_code}")
|
|
|
|
print("⏰ Processing timeout after 3 minutes")
|
|
return False
|
|
else:
|
|
print(f"❌ Upload failed: {upload_response.status_code}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
debug_ocr_timeout() |