chore: make daphne/asgi optional for now

This commit is contained in:
Yohan Boniface 2024-10-14 12:10:13 +02:00
parent aa246aaf05
commit b3e88b6096
3 changed files with 5 additions and 16 deletions

View file

@ -28,8 +28,6 @@ classifiers = [
"Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.12",
] ]
dependencies = [ dependencies = [
"channels==4.0.0",
"daphne==4.1.0",
"Django==5.1.1", "Django==5.1.1",
"django-agnocomplete==2.2.0", "django-agnocomplete==2.2.0",
"django-environ==0.11.2", "django-environ==0.11.2",
@ -69,6 +67,10 @@ test = [
docker = [ docker = [
"uwsgi==2.0.27", "uwsgi==2.0.27",
] ]
sync = [
"channels==4.1.0",
"daphne==4.1.2",
]
[project.scripts] [project.scripts]
umap = "umap.bin:main" umap = "umap.bin:main"

View file

@ -1,10 +1,7 @@
import os import os
from channels.auth import AuthMiddlewareStack from channels.routing import ProtocolTypeRouter
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.security.websocket import AllowedHostsOriginValidator
from django.core.asgi import get_asgi_application from django.core.asgi import get_asgi_application
from django.urls import re_path
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "umap.settings") os.environ.setdefault("DJANGO_SETTINGS_MODULE", "umap.settings")
# Initialize Django ASGI application early to ensure the AppRegistry # Initialize Django ASGI application early to ensure the AppRegistry
@ -15,14 +12,5 @@ application = ProtocolTypeRouter(
{ {
"http": django_asgi_app, "http": django_asgi_app,
# Just HTTP for now. (We can add other protocols later.) # Just HTTP for now. (We can add other protocols later.)
"websocket": AllowedHostsOriginValidator(
AuthMiddlewareStack(
URLRouter(
[
re_path(r"^ws/$", consumers.AsyncChatConsumer.as_asgi()),
]
)
)
),
} }
) )

View file

@ -119,7 +119,6 @@ LANGUAGES = (
SECRET_KEY = env("SECRET_KEY", default=None) SECRET_KEY = env("SECRET_KEY", default=None)
INSTALLED_APPS = ( INSTALLED_APPS = (
"daphne",
"django.contrib.auth", "django.contrib.auth",
"django.contrib.contenttypes", "django.contrib.contenttypes",
"django.contrib.sessions", "django.contrib.sessions",