{"id":16795896,"url":"https://github.com/mvolfik/starlette-websockets-demo","last_synced_at":"2025-04-11T00:11:44.519Z","repository":{"id":39584610,"uuid":"331026076","full_name":"mvolfik/starlette-websockets-demo","owner":"mvolfik","description":"Demo of server-sent broadcast notifications on multiple channels, using Python Starlette framework with Websockets","archived":false,"fork":false,"pushed_at":"2022-05-31T15:26:53.000Z","size":30,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T00:11:32.213Z","etag":null,"topics":["notifications","python","starlette","websocket","websockets"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mvolfik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-19T15:33:16.000Z","updated_at":"2024-07-19T04:34:33.000Z","dependencies_parsed_at":"2022-09-03T11:50:49.454Z","dependency_job_id":null,"html_url":"https://github.com/mvolfik/starlette-websockets-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvolfik%2Fstarlette-websockets-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvolfik%2Fstarlette-websockets-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvolfik%2Fstarlette-websockets-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvolfik%2Fstarlette-websockets-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvolfik","download_url":"https://codeload.github.com/mvolfik/starlette-websockets-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317729,"owners_count":21083530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notifications","python","starlette","websocket","websockets"],"created_at":"2024-10-13T09:17:41.348Z","updated_at":"2025-04-11T00:11:44.502Z","avatar_url":"https://github.com/mvolfik.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a demo of using the Python [Starlette](https://github.com/encode/starlette)\nframework for websockets-based subscription to server events on multiple, dynamically\ncreated and deleted channels.\n\nRun with\n\n```shell\npipenv --python 3.8\npipenv shell\npipenv install\nuvicorn starlette_websocket_demo:app\n```\n\n# Protocol\n\nThis is meant to be server-sent events, which are implemented via the websockets.\nHowever, for convenient usage demonstration, there are some HTTP endpoints for channel\nmanagement and sending messages\n\n## Websocket protocol\n\n### Client messages\n\n- `subtest123`: subscribe me to channel `test123`\n- `poptest123`: unsubscribe me from channel `test123`\n\n### Server messages\n\nJSON formatted. Message type is stored in field `t`, channel id is in field `id`.\n\n- type `new`: new channel advertisement – means that the given channel was just created\n  and can be subscribed to\n- type `del`: channel deletion notice – the given channel was deleted, and the client\n  automatically unsubscribed\n- type `msg`: incoming message – a message was sent to the given channel, the message\n  data are stored under the field `msg` (can be structured data)\n\nAll channels are automatically unsubscribed upon disconnection (from any side). No\nmessages are preserved on server, they are just sent to all clients subscribed to the\ngiven channel at the moment the message was received.\n\n## HTTP endpoints\n\n- `GET /new-channel?id={id}` – create a channel with the given ID (will be immediately\n  advertised to clients)\n- `GET /del-channel?id={id}` – delete the channel with the given ID\n- `POST /push/{id}` – send a message to the channel with the given ID, the data\n  is `application/json` in the request body\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvolfik%2Fstarlette-websockets-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvolfik%2Fstarlette-websockets-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvolfik%2Fstarlette-websockets-demo/lists"}