| """ | |
| Test the Etymology API endpoint | |
| """ | |
| import requests | |
| import json | |
| # Test the unified endpoint | |
| def test_etymology_illustration(): | |
| url = "http://localhost:8000/api/v1/generate_illustration" | |
| payload = { | |
| "word": "mercenaries", | |
| "etymology_context": "From Latin 'mercenarius' meaning hired soldier, from 'merces' (wages)", | |
| "style": "historical_illustration" | |
| } | |
| print("Testing Etymology API...") | |
| print(f"Request: {json.dumps(payload, indent=2)}") | |
| try: | |
| response = requests.post(url, json=payload) | |
| print(f"\nStatus: {response.status_code}") | |
| print(f"Response: {json.dumps(response.json(), indent=2)}") | |
| except Exception as e: | |
| print(f"Error: {e}") | |
| if __name__ == "__main__": | |
| # First check health | |
| try: | |
| health = requests.get("http://localhost:8000/health") | |
| print(f"Health Check: {health.json()}\n") | |
| except: | |
| print("⚠️ API not responding. Start with: python etymology_api.py\n") | |
| test_etymology_illustration() | |