The following repo contains code on how to build Django Channels into your application with endpoints created by Django REST framework.
- Install brew from https://brew.sh/
- Install python and pip from brew
- Install redis from brew:
brew install redis
- Start the redis service
brew services start redis
- Create a virtual environment by running
virtualenv env
in the terminal. - Activate this python environment:
source env/bin/activate
- Install all dependancies found in the requirements.txt. From terminal, run
pip install -r requirements.txt
- Go into the prototype directory:
cd prototype
- Migrate:
python manage.py migrate
- Populate the database with some broadcasting channels:
python manage.py populate_db
- Run the server:
python manage.py runserver
- Open up your browser and go to localhost:8000/channels. Open up the console and there is a confirmation message to assert the connection was successful.
- With a tool like Postman, you can send PUT requests (as shown below) to update the database.
The results will update in real time without the client initially sending off HTTP requests!