48 lines
2.2 KiB
Python
48 lines
2.2 KiB
Python
import requests
|
|
import time
|
|
|
|
def reupload_document():
|
|
base_url = 'http://localhost:3015'
|
|
headers = {'X-API-Key': 'jleu1212', 'Content-Type': 'application/json'}
|
|
|
|
# First, delete the existing document
|
|
print('🗑️ Deleting existing document...')
|
|
response = requests.delete(f'{base_url}/documents', headers=headers, timeout=10)
|
|
print(f'Delete status: {response.status_code}')
|
|
|
|
if response.status_code == 200:
|
|
print('✅ Document deleted successfully')
|
|
|
|
# Wait a moment for deletion to complete
|
|
time.sleep(2)
|
|
|
|
# Now re-upload the test.docx with the updated processor
|
|
print('📤 Re-uploading test.docx with updated processor...')
|
|
files = {'file': ('test.docx', open('test.docx', 'rb'), 'application/vnd.openxmlformats-officedocument.wordprocessingml.document')}
|
|
upload_response = requests.post(f'{base_url}/upload', files=files, headers={'X-API-Key': 'jleu1212'}, timeout=30)
|
|
|
|
print(f'Upload status: {upload_response.status_code}')
|
|
if upload_response.status_code == 200:
|
|
print('✅ Document uploaded successfully')
|
|
print('Waiting 10 seconds for processing...')
|
|
time.sleep(10)
|
|
|
|
# Check if document now contains classification
|
|
doc_response = requests.get(f'{base_url}/documents', headers=headers, timeout=10)
|
|
if doc_response.status_code == 200:
|
|
data = doc_response.json()
|
|
if data['statuses']['processed']:
|
|
doc = data['statuses']['processed'][0]
|
|
print(f'\n📄 Updated Document:')
|
|
print(f' Content Summary: {doc["content_summary"]}')
|
|
if 'Image Classifications:' in doc['content_summary']:
|
|
print('✅ SUCCESS: Document now contains classification metadata!')
|
|
else:
|
|
print('❌ Still no classification metadata - processor may not be updated')
|
|
else:
|
|
print(f'❌ Upload failed: {upload_response.text}')
|
|
else:
|
|
print('❌ Failed to delete document')
|
|
|
|
if __name__ == '__main__':
|
|
reupload_document() |