Example with backend and frontend for django-instant
git clone https://github.com/synw/django-instant-example
cd backend
virtualenv . && source bin/activate
pip install -r requirements.txt
Run
cd instant_backend
python3 manage.py runserver
The backend is available at localhost:8000
. It provides an sqlite database
with a user adminuser
with the password adminpwd
. Some channels are created
in the backend: a public channel, a user channel and a group channel. Check the
admin
Install a Centrifugo server locally:
cd backend/instant_backend
python manage.py installws
Run the websockets server:
cd backend/instant_backend
python manage.py runws
cd frontend
npm install
# or yarn install
npm run dev
# or yarn dev
The frontend is available at localhost:3000
Open the frontend, login and connect. Then open a backend shell to send a message:
cd instant_backend
python3 manage.py shell
Then send a message:
In [1]: from instant.producers import publish
In [2]: publish("public", "message content")
The message will appear on the frontend