Skip to content

Commit 8a8a8df

Browse files
committed
Initial commit
0 parents  commit 8a8a8df

File tree

21 files changed

+352
-0
lines changed

21 files changed

+352
-0
lines changed

.gitignore

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Python template
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
env/
14+
build/
15+
develop-eggs/
16+
dist/
17+
downloads/
18+
eggs/
19+
.eggs/
20+
lib/
21+
lib64/
22+
parts/
23+
sdist/
24+
var/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.coverage
43+
.coverage.*
44+
.cache
45+
nosetests.xml
46+
coverage.xml
47+
*,cover
48+
49+
# Translations
50+
*.mo
51+
*.pot
52+
53+
# Django stuff:
54+
*.log
55+
56+
# Sphinx documentation
57+
docs/_build/
58+
59+
# PyBuilder
60+
target/
61+
62+
db.sqlite3
63+
.idea/

blog_channels/__init__.py

Whitespace-only changes.

blog_channels/asgi.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import os
2+
import channels.asgi
3+
4+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'blog_channels.settings')
5+
channel_layer = channels.asgi.get_channel_layer()

blog_channels/routing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from channels.routing import route
2+
3+
4+
channel_routing = {
5+
'websocket.connect': 'chat.consumers.ws_connect',
6+
'websocket.receive': 'chat.consumers.ws_message',
7+
'websocket.disconnect': 'chat.consumers.ws_disconnect',
8+
'send_email': 'chat.consumers.send_email_consumer'
9+
}

blog_channels/settings.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
2+
import os
3+
4+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
5+
6+
SECRET_KEY = '03zg-#q0r$3u#6e-%oifn!ea^d+=d+^77ep7xq(!e)jxbiw%%('
7+
8+
DEBUG = True
9+
10+
ALLOWED_HOSTS = []
11+
12+
13+
INSTALLED_APPS = [
14+
'django.contrib.admin',
15+
'django.contrib.auth',
16+
'django.contrib.contenttypes',
17+
'django.contrib.sessions',
18+
'django.contrib.messages',
19+
'django.contrib.staticfiles',
20+
'channels',
21+
]
22+
23+
MIDDLEWARE_CLASSES = [
24+
'django.middleware.security.SecurityMiddleware',
25+
'django.contrib.sessions.middleware.SessionMiddleware',
26+
'django.middleware.common.CommonMiddleware',
27+
'django.middleware.csrf.CsrfViewMiddleware',
28+
'django.contrib.auth.middleware.AuthenticationMiddleware',
29+
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
30+
'django.contrib.messages.middleware.MessageMiddleware',
31+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
32+
]
33+
34+
ROOT_URLCONF = 'blog_channels.urls'
35+
36+
TEMPLATES = [
37+
{
38+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
39+
'DIRS': [os.path.join(BASE_DIR, 'templates')]
40+
,
41+
'APP_DIRS': True,
42+
'OPTIONS': {
43+
'context_processors': [
44+
'django.template.context_processors.debug',
45+
'django.template.context_processors.request',
46+
'django.contrib.auth.context_processors.auth',
47+
'django.contrib.messages.context_processors.messages',
48+
],
49+
},
50+
},
51+
]
52+
53+
WSGI_APPLICATION = 'blog_channels.wsgi.application'
54+
55+
56+
DATABASES = {
57+
'default': {
58+
'ENGINE': 'django.db.backends.sqlite3',
59+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
60+
}
61+
}
62+
63+
64+
AUTH_PASSWORD_VALIDATORS = [
65+
{
66+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
67+
},
68+
{
69+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
70+
},
71+
{
72+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
73+
},
74+
{
75+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
76+
},
77+
]
78+
79+
80+
LANGUAGE_CODE = 'en-us'
81+
82+
TIME_ZONE = 'UTC'
83+
84+
USE_I18N = True
85+
86+
USE_L10N = True
87+
88+
USE_TZ = True
89+
90+
STATIC_URL = '/static/'
91+
92+
93+
CHANNEL_LAYERS = {
94+
'default': {
95+
'BACKEND': 'asgi_redis.RedisChannelLayer',
96+
'CONFIG': {
97+
'hosts': [('localhost', 6379)],
98+
},
99+
'ROUTING': 'blog_channels.routing.channel_routing',
100+
},
101+
}
102+
103+
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

blog_channels/urls.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.conf.urls import url, include
2+
from django.contrib import admin
3+
4+
urlpatterns = {
5+
url(r'^admin/', admin.site.urls),
6+
url(r'^chat/', include('chat.urls', namespace='chat')),
7+
}

blog_channels/wsgi.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for blog_channels project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "blog_channels.settings")
15+
16+
application = get_wsgi_application()

chat/__init__.py

Whitespace-only changes.

chat/admin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

chat/apps.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class ChatConfig(AppConfig):
5+
name = 'chat'

0 commit comments

Comments
 (0)