From 7098714788a9dcfad4d8e5176a7bffe44c4175d7 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Tue, 17 Nov 2020 23:42:59 +0100 Subject: [PATCH] Add requirements --- asgi.py | 18 ------------------ docker-compose.yaml | 12 ------------ mi_web/asgi.py | 24 +++++++++++++----------- mi_web/settings.py | 9 +++------ mi_web/wsgi.py | 16 ---------------- requirements.txt | 6 ++++++ 6 files changed, 22 insertions(+), 63 deletions(-) delete mode 100644 asgi.py delete mode 100644 mi_web/wsgi.py create mode 100644 requirements.txt diff --git a/asgi.py b/asgi.py deleted file mode 100644 index 4141348..0000000 --- a/asgi.py +++ /dev/null @@ -1,18 +0,0 @@ -import os - -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mi_web.settings") -import django - -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 - - -application = ProtocolTypeRouter( - { - "websocket": AuthMiddlewareStack(URLRouter(websocket_urlpatterns)), - } -) diff --git a/docker-compose.yaml b/docker-compose.yaml index 67ed10b..0b9d3b3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -2,20 +2,8 @@ version: '3.1' services: - db: - image: postgres - restart: always - volumes: - - ./postgres:/var/lib/postgresql/data - environment: - POSTGRES_DB: postgres - POSTGRES_PASSWORD: postgres - ports: - - 5432:5432 - redis: image: redis:alpine restart: always ports: - 6379:6379 - diff --git a/mi_web/asgi.py b/mi_web/asgi.py index 9a0990c..4141348 100644 --- a/mi_web/asgi.py +++ b/mi_web/asgi.py @@ -1,16 +1,18 @@ -""" -ASGI config for mi_web project. - -It exposes the ASGI callable as a module-level variable named ``application``. - -For more information on this file, see -https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/ -""" - import os +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mi_web.settings") +import django + +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 -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mi_web.settings') -application = get_asgi_application() +application = ProtocolTypeRouter( + { + "websocket": AuthMiddlewareStack(URLRouter(websocket_urlpatterns)), + } +) diff --git a/mi_web/settings.py b/mi_web/settings.py index 713a431..2684f4e 100644 --- a/mi_web/settings.py +++ b/mi_web/settings.py @@ -77,12 +77,8 @@ TEMPLATES = [ DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql', - 'NAME': 'postgres', - 'USER': 'postgres', - 'PASSWORD': 'postgres', - 'HOST': '127.0.0.1', - 'PORT': '5432', + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'mydatabase', } } @@ -126,6 +122,7 @@ USE_TZ = False STATIC_URL = '/static/' ASGI_APPLICATION = "asgi.application" + CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", diff --git a/mi_web/wsgi.py b/mi_web/wsgi.py deleted file mode 100644 index b9c965b..0000000 --- a/mi_web/wsgi.py +++ /dev/null @@ -1,16 +0,0 @@ -""" -WSGI config for mi_web 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/3.1/howto/deployment/wsgi/ -""" - -import os - -from django.core.wsgi import get_wsgi_application - -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mi_web.settings') - -application = get_wsgi_application() diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..aa29aed --- /dev/null +++ b/requirements.txt @@ -0,0 +1,6 @@ +# Servidor asincrono para Django +daphne==2.4.1 +# Channels +channels==2.4.0 +# Conector de Redis para Channels +channels_redis