65 lines
2.2 KiB
Python
65 lines
2.2 KiB
Python
import requests
|
|
import json
|
|
|
|
def test_webui_access():
|
|
"""Test accessing the WebUI and uploading OCR PDF through the interface"""
|
|
|
|
base_url = "http://localhost:3015"
|
|
|
|
try:
|
|
# Test basic server access
|
|
response = requests.get(f"{base_url}/")
|
|
print(f"WebUI status: {response.status_code}")
|
|
|
|
if response.status_code == 200:
|
|
print("✓ WebUI is accessible")
|
|
else:
|
|
print(f"✗ WebUI access failed: {response.status_code}")
|
|
return False
|
|
|
|
# Test login endpoint
|
|
login_data = {
|
|
"username": "jleu3482",
|
|
"password": "jleu1212"
|
|
}
|
|
|
|
login_response = requests.post(f"{base_url}/login", json=login_data)
|
|
print(f"Login status: {login_response.status_code}")
|
|
|
|
if login_response.status_code == 200:
|
|
print("✓ Login successful")
|
|
# Get auth token if available
|
|
if login_response.json().get('access_token'):
|
|
print("✓ Authentication token received")
|
|
else:
|
|
print(f"✗ Login failed: {login_response.status_code}")
|
|
print(f"Response: {login_response.text}")
|
|
return False
|
|
|
|
# Check document status
|
|
docs_response = requests.get(f"{base_url}/documents")
|
|
print(f"Documents status: {docs_response.status_code}")
|
|
|
|
if docs_response.status_code == 200:
|
|
docs_data = docs_response.json()
|
|
print(f"Current document status: {json.dumps(docs_data, indent=2)}")
|
|
else:
|
|
print(f"✗ Documents check failed: {docs_response.status_code}")
|
|
|
|
return True
|
|
|
|
except Exception as e:
|
|
print(f"Error testing WebUI: {e}")
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
print("Testing WebUI access and authentication...")
|
|
success = test_webui_access()
|
|
|
|
if success:
|
|
print("\n✓ WebUI testing completed successfully")
|
|
print("\nYou can now access the WebUI at: http://localhost:3015")
|
|
print("Use credentials: jleu3482 / jleu1212")
|
|
print("Upload the ocr.pdf file through the WebUI interface")
|
|
else:
|
|
print("\n✗ WebUI testing failed") |