From 2c48dabfab4abf7c755e6be00ef5a76f29525e8a Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Thu, 5 Sep 2024 21:43:42 -0700 Subject: [PATCH] add preliminary support for ASGI/daphne serving --- archivebox/core/asgi.py | 28 ++++++++++++++++++++++++++++ archivebox/core/settings.py | 1 + 2 files changed, 29 insertions(+) create mode 100644 archivebox/core/asgi.py diff --git a/archivebox/core/asgi.py b/archivebox/core/asgi.py new file mode 100644 index 00000000..ee300457 --- /dev/null +++ b/archivebox/core/asgi.py @@ -0,0 +1,28 @@ +""" +WSGI config for archivebox 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/2.1/howto/deployment/wsgi/ +""" + +import os + +from archivebox.config import setup_django + +setup_django(in_memory_db=False, check_db=True) + + +from django.core.asgi import get_asgi_application +from channels.routing import ProtocolTypeRouter + + +django_asgi_app = get_asgi_application() + +application = ProtocolTypeRouter( + { + "http": django_asgi_app, + # Just HTTP for now. (We can add other protocols later.) + } +) diff --git a/archivebox/core/settings.py b/archivebox/core/settings.py index 1a765499..8c23bf2c 100644 --- a/archivebox/core/settings.py +++ b/archivebox/core/settings.py @@ -65,6 +65,7 @@ PLUGIN_KEYS = AttrDict({ ################################################################################ WSGI_APPLICATION = 'core.wsgi.application' +ASGI_APPLICATION = "core.asgi.application" ROOT_URLCONF = 'core.urls' LOGIN_URL = '/accounts/login/'