Код: Выделить всё
import requests
from sseclient import SSEClient
def get_sse(url):
try:
# Make the request to the SSE endpoint
response = requests.get(url, stream=True)
# Create an SSEClient instance with the response stream
client = SSEClient(response)
# Process each event received
for event in client.events():
print(f"Received event: {event.data}")
except requests.exceptions.RequestException as e:
print(f"Request exception: {e}")
except KeyboardInterrupt:
print("Connection closed by user")
if __name__ == "__main__":
sse_url = 'http://mywebsite.com/endpoint.php' # Replace with your SSE endpoint
get_sse(sse_url)
< /code>
endpoint.php
Подробнее здесь: [url]https://stackoverflow.com/questions/78950844/request-exception-connection-aborted-remotedisconnectedremote-end-closed[/url]