Fix bad names

This commit is contained in:
Andros Fenollosa 2021-03-08 21:25:34 +01:00
parent 91a01428fe
commit e3e1a0144c
11 changed files with 25 additions and 33 deletions

View File

@ -1,4 +1,4 @@
http://guitarlions.localhost
http://my-demo.localhost
root * /usr/src/app/

View File

@ -1,8 +1,7 @@
import json
from channels.generic.websocket import AsyncWebsocketConsumer
from asgiref.sync import sync_to_async
class BackConsumer(AsyncWebsocketConsumer):
class BlogConsumer(AsyncWebsocketConsumer):
def connect(self):
''' Cliente se conecta '''
@ -12,15 +11,15 @@ class BackConsumer(AsyncWebsocketConsumer):
self.room_group_name = "blog_%s" % self.room_name
# Se une a la sala
await self.channel_layer.group_add(self.room_group_name, self.channel_name)
self.channel_layer.group_add(self.room_group_name, self.channel_name)
# Informa al cliente del éxito
await self.accept()
self.accept()
def disconnect(self, close_code):
''' Cliente se desconecta '''
# Leave room group
await self.channel_layer.group_discard(self.room_group_name, self.channel_name)
self.channel_layer.group_discard(self.room_group_name, self.channel_name)
def receive(self, text_data):
''' Cliente envía información y nosotros la recibimos '''
@ -29,7 +28,7 @@ class BackConsumer(AsyncWebsocketConsumer):
text = text_data_json["text"]
# Enviamos el mensaje a la sala
await self.channel_layer.group_send(
self.channel_layer.group_send(
self.room_group_name,
{
"type": "chat_message",
@ -44,7 +43,7 @@ class BackConsumer(AsyncWebsocketConsumer):
text = event["text"]
# Send message to WebSocket
await self.send(
self.send(
text_data=json.dumps(
{
"type": "chat_message",

11
asgi.py
View File

@ -1,11 +0,0 @@
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings")
import django
django.setup()
from channels.routing import ProtocolTypeRouter
application = ProtocolTypeRouter({})

View File

@ -11,4 +11,4 @@ python3 manage.py migrate
# Start server
echo "Starting server"
uvicorn --host 0.0.0.0 --port 8000 --reload chapps.asgi:application
uvicorn --host 0.0.0.0 --port 8000 --reload my_demo.asgi:application

View File

@ -11,4 +11,4 @@ python3 manage.py migrate
# Start server
echo "Starting server"
uvicorn --host 0.0.0.0 --port 8000 chapps.asgi:application
uvicorn --host 0.0.0.0 --port 8000 my_demo.asgi:application

View File

@ -6,7 +6,7 @@ import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mi_web.settings')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_demo.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:

View File

@ -1,6 +1,6 @@
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mi_web.settings")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_demo.settings")
import django
django.setup()
@ -8,7 +8,7 @@ django.setup()
from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
from apps.chat.routing import websocket_urlpatterns
from apps.back.routing import websocket_urlpatterns
application = ProtocolTypeRouter(

View File

@ -1,5 +1,5 @@
"""
Django settings for mi_web project.
Django settings for my_demo project.
Generated by 'django-admin startproject' using Django 3.1.3.
@ -38,7 +38,7 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'channels',
'apps.chat',
'apps.back',
'apps.front',
]
@ -52,7 +52,7 @@ MIDDLEWARE = [
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'mi_web.urls'
ROOT_URLCONF = 'my_demo.urls'
TEMPLATES = [
{
@ -77,8 +77,12 @@ TEMPLATES = [
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mydatabase',
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'demo',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}

View File

@ -1,10 +1,10 @@
# Django
django
# Servidor para Django
daphne==2.4.1
# Conector para PostgreSQL
# ASGI server
uvicorn
# Connect PostgreSQL
psycopg2-binary
# Channels
channels==2.4.0
# Conector de Redis para Channels
# Connect Redis for Channels
channels_redis