This commit is contained in:
retoor 2024-12-29 17:28:41 +01:00
parent 0072e6d86e
commit d74e68d593

View File

@ -154,20 +154,16 @@ class Application(BaseApplication):
self.router.add_get("/ws/{uuid}", self.websocket_handler)
async def websocket_handler(self, request):
# Extract the UUID from the route
uuid_value = request.match_info["uuid"]
# Validate if it's a valid UUID
try:
uuid_obj = uuid.UUID(uuid_value)
except ValueError:
return web.Response(text="Invalid UUID", status=400)
# Upgrade the connection to WebSocket
ws = web.WebSocketResponse()
await ws.prepare(request)
print(f"WebSocket connection established with UUID: {uuid_obj}")
component = App(self, "app", ws=ws)
await component.service()