chat-app-package 0.1

Creator: codyrutscher

Last updated:

0 purchases

chat-app-package 0.1 Image
chat-app-package 0.1 Images
Add to Cart

Description:

chatapppackage 0.1

Chat is a Django app to conduct Web-based Chat. For each question,
visitors can choose between a fixed number of answers.
Detailed documentation is in the “docs” directory.

Quick start

Add “chat” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...
'chat',
]

USE_DEFAULT_TEMPLATES=False

Include the chat URLconf in your project urls.py like this:
path('chat/', include('chat.urls')),

Run python manage.py migrate to create the chat models.
Add to settings.py this:
ASGI_APPLICATION = 'your_project_name.asgi.application'

CHANNEL_LAYERS = {
'default': {
'BACKEND': 'channels_redis.core.RedisChannelLayer',
'CONFIG': {
"hosts": [('127.0.0.1', 6379)],
},
},
}

WEBSOCKETPATH='127.0.0.1:8000'

Create routing.py file in project folder:
from django.urls import path
from channels.routing import URLRouter
from chat.consumers import ChatConsumer

ws_application = [
path("ws/chat/",ChatConsumer.as_asgi())
]

Write in asgi.py file in project folder:
import os
from channels.routing import URLRouter,ProtocolTypeRouter
from channels.security.websocket import AllowedHostsOriginValidator
from channels.auth import AuthMiddlewareStack
from django.core.asgi import get_asgi_application
from .routing import ws_application

application = ProtocolTypeRouter({
'websocket': AllowedHostsOriginValidator(
AuthMiddlewareStack(
URLRouter(
ws_application
)
)
)
})

Start the development server and visit http://127.0.0.1:8000/admin/
to create a chat (you’ll need the Admin app enabled).
Visit http://127.0.0.1:8000/chat/ to participate in the chat.
If you want to use your template:
write views.py

from chat.use_customs import CustomTemplate

CustomTemplate.chat_template_name='mychat.html'
CustomTemplate.login_template_name='mylogin.html'
CustomTemplate.signup_template_name='mysignup.html'

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.