mirror of
https://github.com/django/daphne.git
synced 2025-07-14 18:02:17 +03:00
Small project to test with
This commit is contained in:
parent
cac848fc89
commit
e1bf2f5982
0
testproject/chtest/__init__.py
Normal file
0
testproject/chtest/__init__.py
Normal file
4
testproject/chtest/consumers.py
Normal file
4
testproject/chtest/consumers.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
def ws_message(message):
|
||||||
|
"Echoes messages back to the client"
|
||||||
|
message.reply_channel.send(message.content)
|
3
testproject/chtest/models.py
Normal file
3
testproject/chtest/models.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
10
testproject/manage.py
Normal file
10
testproject/manage.py
Normal 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)
|
0
testproject/testproject/__init__.py
Normal file
0
testproject/testproject/__init__.py
Normal file
36
testproject/testproject/settings.py
Normal file
36
testproject/testproject/settings.py
Normal 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"
|
7
testproject/testproject/urls.py
Normal file
7
testproject/testproject/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django.conf.urls import include, url
|
||||||
|
from chtest import consumers
|
||||||
|
urlpatterns = []
|
||||||
|
|
||||||
|
channel_routing = {
|
||||||
|
"websocket.message": consumers.ws_message,
|
||||||
|
}
|
16
testproject/testproject/wsgi.py
Normal file
16
testproject/testproject/wsgi.py
Normal 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()
|
Loading…
Reference in New Issue
Block a user