Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple sse example #293

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove clock class, don't need it
Co-authored-by: Daniel Roy Greenfeld <daniel@feldroy.com>
  • Loading branch information
audreyfeldroy and pydanny committed Aug 14, 2024
commit 3e5b263ce6df7962e606b8aaefe93bb92db7c9df
4 changes: 2 additions & 2 deletions examples/sse_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
@rt("/")
def get():
return Titled("SSE Clock",
P("XX:XX", cls="clock", sse_swap="TimeUpdateEvent",
P("XX:XX", sse_swap="TimeUpdateEvent",
hx_ext="sse", sse_connect="/time-sender"))

async def time_generator():
while True:
yield f"""event: TimeUpdateEvent\ndata: {to_xml(P(datetime.now().strftime('%H:%M:%S'), cls="clock", sse_swap="TimeUpdateEvent"))}\n\n"""
yield f"""event: TimeUpdateEvent\ndata: {to_xml(P(datetime.now().strftime('%H:%M:%S'), sse_swap="TimeUpdateEvent"))}\n\n"""
await asyncio.sleep(1)

@rt("/time-sender")
Expand Down
Loading