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()