mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 01:58:23 +02:00
First play with websockets
Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
14
tfjm/asgi.py
14
tfjm/asgi.py
@ -12,8 +12,20 @@ https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
|
||||
|
||||
import os
|
||||
|
||||
from channels.auth import AuthMiddlewareStack
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
from channels.security.websocket import AllowedHostsOriginValidator
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
import draw.routing
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'tfjm.settings')
|
||||
|
||||
application = get_asgi_application()
|
||||
application = ProtocolTypeRouter(
|
||||
{
|
||||
"http": get_asgi_application(),
|
||||
"websocket": AllowedHostsOriginValidator(
|
||||
AuthMiddlewareStack(URLRouter(draw.routing.websocket_urlpatterns))
|
||||
),
|
||||
}
|
||||
)
|
||||
|
@ -42,6 +42,8 @@ ALLOWED_HOSTS = ['*']
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'daphne',
|
||||
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
@ -51,6 +53,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.staticfiles',
|
||||
'django.forms',
|
||||
|
||||
'channels',
|
||||
'crispy_forms',
|
||||
'crispy_bootstrap5',
|
||||
'django_filters',
|
||||
@ -111,6 +114,7 @@ TEMPLATES = [
|
||||
|
||||
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
|
||||
|
||||
ASGI_APPLICATION = 'tfjm.asgi.application'
|
||||
WSGI_APPLICATION = 'tfjm.wsgi.application'
|
||||
|
||||
|
||||
@ -249,6 +253,13 @@ FORBIDDEN_TRIGRAMS = [
|
||||
"SEX",
|
||||
]
|
||||
|
||||
# TODO: Use a redis server in production
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels.layers.InMemoryChannelLayer"
|
||||
}
|
||||
}
|
||||
|
||||
if os.getenv("TFJM_STAGE", "dev") == "prod": # pragma: no cover
|
||||
from .settings_prod import * # noqa: F401,F403
|
||||
else:
|
||||
|
Reference in New Issue
Block a user