Skip to content

Latest commit

 

History

History
10 lines (6 loc) · 1014 Bytes

README.md

File metadata and controls

10 lines (6 loc) · 1014 Bytes

fasthtml-sse

This example implements a chatbot. Most parts are copied from the fasthtml chatbot example.

However instead of using websockets, this example uses server-sent events (SSE) to send messages from the server to the client.

On message submission, the server responds with 2 message Divs - the user message and an empty assistant message.
This assistant message element initializes the SSE connection and receives the streaming messages from the server. After the final message is sent, a close event from the server closes the connection.

This process repeats on every message submission. As the connection to the server is terminated after every message, the server only needs to be running a couple of (milli-)seconds, enabling deployments using serverless functions like AWS Lambda or Azure Functions.