https://github.com/tokeshu/eventsource-parser
A pure python, framework agnostic EventSource parser
https://github.com/tokeshu/eventsource-parser
Last synced: about 1 month ago
JSON representation
A pure python, framework agnostic EventSource parser
- Host: GitHub
- URL: https://github.com/tokeshu/eventsource-parser
- Owner: tOkeshu
- License: apache-2.0
- Created: 2013-02-16T21:33:03.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2013-02-28T21:24:39.000Z (over 12 years ago)
- Last Synced: 2025-10-05T18:58:25.727Z (about 1 month ago)
- Language: Python
- Size: 137 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE.txt
Awesome Lists containing this project
README
EventSource Parser
==================
A framework agnostic EventSource Parser.
::
>>> source =
"""
id: 1
event: chat
data: hey, how are you?
id: 2
event: chat
data: fine, thank you
:ping
"""
>>> from eventsource_parser import parse
>>> event, rest = parse(source)
>>> event
Event(1, 'chat', 'hey, how are you?')
>>> rest
"id: 2\nevent: chat\ndata: fine, thank you\n\n:ping\n"
>>> event, rest = parse(rest)
>>> event
Event(2, 'chat', 'fine, thank you')
>>> rest
":ping\n"
>>> event, rest = parse(rest)
>>> event
None
>>> rest
""
License
-------
Licensed under the Apache License, Version 2.0.