diff --git a/api/asgi.py b/api/asgi.py index 2775edf..a40b809 100644 --- a/api/asgi.py +++ b/api/asgi.py @@ -9,16 +9,9 @@ https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ import os -from channels.routing import ProtocolTypeRouter, URLRouter -from channels.auth import AuthMiddlewareStack from django.core.asgi import get_asgi_application -from .urls import ws_urlpatterns + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "api.settings") -application = ProtocolTypeRouter( - { - "http": get_asgi_application(), - # "websocket": AuthMiddlewareStack(URLRouter(ws_urlpatterns)), - } -) +application =get_asgi_application() \ No newline at end of file diff --git a/api/settings.py b/api/settings.py index 5401722..79fd0bf 100644 --- a/api/settings.py +++ b/api/settings.py @@ -130,14 +130,15 @@ else: # 配置缓存 CACHES = PROD_CACHES - CHANNEL_LAYERS = { - "default": { - "BACKEND": "channels_redis.core.RedisChannelLayer", - "CONFIG": { - "hosts": [(os.getenv("REDIS_HOST"), 6379)], - }, - }, - } + # WebSocket 的缓存 + # CHANNEL_LAYERS = { + # "default": { + # "BACKEND": "channels_redis.core.RedisChannelLayer", + # "CONFIG": { + # "hosts": [(os.getenv("REDIS_HOST"), 6379)], + # }, + # }, + # } # Password validation # https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators diff --git a/api/urls.py b/api/urls.py index 80dbc34..4217da6 100644 --- a/api/urls.py +++ b/api/urls.py @@ -20,7 +20,6 @@ from django.urls import path from django.conf import settings from django.conf.urls.static import static from ninja import NinjaAPI -from .ws import Consumer api = NinjaAPI() @@ -35,8 +34,4 @@ apis = [ path("api/", api.urls), ] -urlpatterns = apis + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) - -ws_urlpatterns = [ - path("ws/", Consumer.as_asgi()), -] +urlpatterns = apis + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) \ No newline at end of file