https://github.com/fcwu/django-realtime-tutorial
Copy from http://maxburstein.com/blog/realtime-django-using-nodejs-and-socketio/
https://github.com/fcwu/django-realtime-tutorial
Last synced: 10 months ago
JSON representation
Copy from http://maxburstein.com/blog/realtime-django-using-nodejs-and-socketio/
- Host: GitHub
- URL: https://github.com/fcwu/django-realtime-tutorial
- Owner: fcwu
- Created: 2014-03-11T09:41:46.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-03-11T09:54:35.000Z (over 12 years ago)
- Last Synced: 2025-03-04T04:30:04.283Z (over 1 year ago)
- Language: Python
- Size: 133 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
django-realtime-tutorial
========================
Copy from http://maxburstein.com/blog/realtime-django-using-nodejs-and-socketio/
```
#https://docs.djangoproject.com/en/dev/topics/install/
sudo apt-get install python-pip
sudo pip install django
#http://redis.io/download
sudo apt-get install redis-server
#https://github.com/andymccurdy/redis-py
sudo pip install redis
#https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
#https://github.com/LearnBoost/socket.io
npm install socket.io
#https://github.com/shtylman/node-cookie
npm install cookie
```
Running
```
python manage.py syncdb
python manage.py createsuperuser
python manage.py runserver localhost:3000
cd nodejs && node chat.js
```
Code flow
---------
send message
```
YOU -> index.html ---------------------> chat.js ------> views.py ------> redis
socket.emit("send_message") django/node_api channel/chat
------> sqlite
create comment in table core_message
```
receive message
```
YOU -> index.html <---------- sqlite (at beginning)
core_messages
<---------- chat.js
subscribe/chat
```