https://github.com/jborrow/fastapi-websockets-demo
A simple demo of websockets with fastapi
https://github.com/jborrow/fastapi-websockets-demo
Last synced: 3 months ago
JSON representation
A simple demo of websockets with fastapi
- Host: GitHub
- URL: https://github.com/jborrow/fastapi-websockets-demo
- Owner: JBorrow
- Created: 2024-05-10T15:37:02.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-10T15:43:50.000Z (about 1 year ago)
- Last Synced: 2024-12-27T06:41:26.667Z (5 months ago)
- Language: HTML
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple FastAPI Websockets Demo
This simple demo contains four parts:
- A very simple FastAPI (actually Starlette, as FastAPI just provides
passthroughs when it comes to websockets) server that provides an
endpoint where you can request squares of fixed colours. It also
provides a HTTP endpoint, too!
- A webpage with a form with R, G, B entries where you can request
squares of the colour you specify. This is primarily used to
demonstrate error handling.
- A webpage with a single button that requests a thousand images
from the server, to demonstrate the speed of websockets. There
are two alternatives: one that uses a single websocket connection,
and another that uses the more traditional approach of opening
a HTTP request per image.To really understand the benefits of websockets, you should
either run this on a remote server, or run it on a local server
with throttling enabled.License: MIT
To run the demo, simply run `uvicorn app:app --port=12345`, and open
the webpages in your browser.