mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-02-16 19:41:03 +03:00
Merge pull request #2608 from stefanitsky/websocket-docs
This commit is contained in:
commit
931e5c4267
|
@ -23,6 +23,7 @@ Contents:
|
|||
deployment-on-heroku
|
||||
deployment-with-docker
|
||||
docker-postgres-backups
|
||||
websocket
|
||||
faq
|
||||
troubleshooting
|
||||
|
||||
|
|
25
docs/websocket.rst
Normal file
25
docs/websocket.rst
Normal file
|
@ -0,0 +1,25 @@
|
|||
.. _websocket:
|
||||
|
||||
=========
|
||||
Websocket
|
||||
=========
|
||||
|
||||
You can enable web sockets if you select ``use_async`` option when creating a project. That indicates whether the project can use web sockets with Uvicorn + Gunicorn.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
JavaScript example: ::
|
||||
|
||||
> ws = new WebSocket('ws://localhost:8000/') // or 'wss://<mydomain.com>/' in prod
|
||||
WebSocket {url: "ws://localhost:8000/", readyState: 0, bufferedAmount: 0, onopen: null, onerror: null, …}
|
||||
> ws.onmessage = event => console.log(event.data)
|
||||
event => console.log(event.data)
|
||||
> ws.send("ping")
|
||||
undefined
|
||||
pong!
|
||||
|
||||
|
||||
If you don't use Traefik, you might have to configure your reverse proxy accordingly (example with Nginx_).
|
||||
|
||||
.. _Nginx: https://www.nginx.com/blog/websocket-nginx/
|
Loading…
Reference in New Issue
Block a user