54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
import requests
|
|
import json
|
|
|
|
def test_server_status():
|
|
"""Test server health and basic functionality"""
|
|
|
|
base_url = "http://localhost:3015"
|
|
|
|
# Test health endpoint
|
|
print("Testing server health...")
|
|
try:
|
|
health_response = requests.get(f"{base_url}/api/health")
|
|
if health_response.status_code == 200:
|
|
print("✅ Server health: OK")
|
|
print(f"Health response: {health_response.text}")
|
|
else:
|
|
print(f"❌ Server health failed: {health_response.status_code}")
|
|
print(f"Health error: {health_response.text}")
|
|
except Exception as e:
|
|
print(f"❌ Server health error: {e}")
|
|
return
|
|
|
|
# Test login with proper format
|
|
print("\nTesting login...")
|
|
login_data = {
|
|
"username": "jleu3482",
|
|
"password": "jleu1212"
|
|
}
|
|
|
|
try:
|
|
login_response = requests.post(
|
|
f"{base_url}/login",
|
|
json=login_data,
|
|
headers={"Content-Type": "application/json"}
|
|
)
|
|
|
|
print(f"Login status: {login_response.status_code}")
|
|
print(f"Login response: {login_response.text}")
|
|
|
|
if login_response.status_code == 200:
|
|
print("✅ Login successful")
|
|
token = login_response.json().get("access_token")
|
|
print(f"Token: {token[:50]}...")
|
|
return token
|
|
else:
|
|
print(f"❌ Login failed with status {login_response.status_code}")
|
|
|
|
except Exception as e:
|
|
print(f"❌ Login error: {e}")
|
|
|
|
return None
|
|
|
|
if __name__ == "__main__":
|
|
test_server_status() |