Skip to content

Commit

Permalink
Small project to test with
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgodwin committed Nov 7, 2015
1 parent cac848f commit e1bf2f5
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 0 deletions.
Empty file added testproject/chtest/__init__.py
Empty file.
4 changes: 4 additions & 0 deletions testproject/chtest/consumers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

def ws_message(message):
"Echoes messages back to the client"
message.reply_channel.send(message.content)
3 changes: 3 additions & 0 deletions testproject/chtest/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
10 changes: 10 additions & 0 deletions testproject/manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)
Empty file.
36 changes: 36 additions & 0 deletions testproject/testproject/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

SECRET_KEY = '-3yt98bfvxe)7+^h#(@8k#1(1m_fpd9x3q2wolfbf^!r5ma62u'

DEBUG = True

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'channels',
)

ROOT_URLCONF = 'testproject.urls'

WSGI_APPLICATION = 'testproject.wsgi.application'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

CHANNEL_BACKENDS = {
"default": {
"BACKEND": "channels.backends.database.DatabaseChannelBackend",
"ROUTING": "testproject.urls.channel_routing",
},
}

if os.environ.get("USEREDIS", None):
CHANNEL_BACKENDS['default']['BACKEND'] = "channels.backends.redis_py.RedisChannelBackend"
7 changes: 7 additions & 0 deletions testproject/testproject/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.conf.urls import include, url
from chtest import consumers
urlpatterns = []

channel_routing = {
"websocket.message": consumers.ws_message,
}
16 changes: 16 additions & 0 deletions testproject/testproject/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for testproject project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings")

application = get_wsgi_application()

0 comments on commit e1bf2f5

Please sign in to comment.