Fix inconsistencies in examples

This commit is contained in:
Allen Porter
2024-12-30 10:08:57 -08:00
parent 0970ef4ae0
commit 1134421a3a
2 changed files with 2 additions and 5 deletions

View File

@@ -106,7 +106,7 @@ def main(port: int, transport: str) -> int:
debug=True, debug=True,
routes=[ routes=[
Route("/sse", endpoint=handle_sse), Route("/sse", endpoint=handle_sse),
Mount("/messages/", app=sse.handle_post_message) Mount("/messages/", app=sse.handle_post_message),
], ],
) )

View File

@@ -11,7 +11,7 @@ Example usage:
# Create Starlette routes for SSE and message handling # Create Starlette routes for SSE and message handling
routes = [ routes = [
Route("/sse", endpoint=handle_sse), Route("/sse", endpoint=handle_sse),
Mount("/messages", endpoint=handle_messages, methods=["POST"]) Mount("/messages", app=sse.handle_post_message),
] ]
# Define handler functions # Define handler functions
@@ -23,9 +23,6 @@ Example usage:
streams[0], streams[1], app.create_initialization_options() streams[0], streams[1], app.create_initialization_options()
) )
async def handle_messages(request):
await sse.handle_post_message(request.scope, request.receive, request._send)
# Create and run Starlette app # Create and run Starlette app
starlette_app = Starlette(routes=routes) starlette_app = Starlette(routes=routes)
uvicorn.run(starlette_app, host="0.0.0.0", port=port) uvicorn.run(starlette_app, host="0.0.0.0", port=port)