#!/usr/bin/env python3 """ Quick Start Demo for OpenResty API Client This script demonstrates the most common usage patterns for the API client. """ from api_client import create_client, APIClientError, AuthenticationError def main(): print("šŸš€ OpenResty API Client - Quick Start Demo") print("=" * 50) # Create client using convenience function print("\n1. Creating API client...") client = create_client() try: # Test main endpoint print("\n2. Testing main endpoint...") response = client.get("/") print(f" āœ… Status: {response['status']}") print(f" āœ… Status Code: {response['status_code']}") print(f" āœ… Content-Type: {response['headers'].get('Content-Type')}") # Test health check print("\n3. Testing health check...") health = client.health_check() print(f" āœ… Health Status: {health['status']}") print(f" āœ… Health Message: {health['message']}") # Display authentication info from headers print("\n4. Authentication Info:") print(f" āœ… Server: {response['headers'].get('server')}") print(f" āœ… X-Powered-By: {response['headers'].get('x-powered-by')}") print(f" āœ… X-Auth-Type: {response['headers'].get('x-auth-type')}") print("\nšŸŽ‰ All tests passed! Your API client is working correctly.") except AuthenticationError as e: print(f"āŒ Authentication failed: {e.message}") print(" Please check your credentials.") except APIClientError as e: print(f"āŒ API error: {e.message}") except Exception as e: print(f"āŒ Unexpected error: {e}") finally: # Always close the client client.close() print("\nšŸ‘‹ Client session closed.") if __name__ == "__main__": main()