Small project to test with

This commit is contained in:
Andrew Godwin 2015-11-07 03:13:15 -08:00
parent cac848fc89
commit e1bf2f5982
8 changed files with 76 additions and 0 deletions

View File

View File

@ -0,0 +1,4 @@
def ws_message(message):
"Echoes messages back to the client"
message.reply_channel.send(message.content)

View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

10
testproject/manage.py Normal file
View File

@ -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)

View File

View File

@ -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"

View File

@ -0,0 +1,7 @@
from django.conf.urls import include, url
from chtest import consumers
urlpatterns = []
channel_routing = {
"websocket.message": consumers.ws_message,
}

View File

@ -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()