import httpx try: with httpx.stream("GET", "http://127.0.0.1:5000/events") as response: response.raise_for_status() for chunk in response.iter_bytes(): print(chunk) except httpx.HTTPStatusError as e: print(f"HTTP error occurred: {e}") except httpx.RequestError as e: print(f"Request error occurred: {e}")