调试 uvicorn

main
RogerWork 1 year ago
parent 90b86d341d
commit 4531100393
  1. 18
      dingxin_toolbox_drf/asgi.py
  2. 13
      dingxin_toolbox_drf/routing.py
  3. 6
      dingxin_toolbox_drf/settings.py
  4. 8
      dingxin_toolbox_drf/urls.py

@ -9,23 +9,15 @@ https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
import os
import django
from django.conf import settings
from django.core.asgi import get_asgi_application
from channels.routing import ProtocolTypeRouter, URLRouter
# from django.conf import settings
# # from django.core.asgi import get_asgi_application
# from channels.routing import ProtocolTypeRouter, URLRouter
from channels.routing import get_default_application
from .urls import websocket_urlpatterns
from .wsgi import *
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'dingxin_toolbox_drf.settings')
# os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'backend.settings')
# application = get_asgi_application()
application = ProtocolTypeRouter(
{
'http': get_asgi_application(),
# 'http': get_default_application(),
'websocket': URLRouter(websocket_urlpatterns)
}
)
settings.configure(DEBUG=True)
django.setup()
application = get_default_application()

@ -0,0 +1,13 @@
from .wsgi import *
# from channels.auth import AuthMiddlewareStack
from channels.routing import ProtocolTypeRouter, URLRouter
from django.core.asgi import get_asgi_application
from .urls import websocket_urlpatterns
application = ProtocolTypeRouter(
{
'http': get_asgi_application(),
'websocket': URLRouter(websocket_urlpatterns)
}
)

@ -31,6 +31,8 @@ SECRET_KEY = 'django-insecure-hfujy!ih1uvio_p^cfdj^%8juf_wdb@szu$t=aaacd)^(zf@b%
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
# 增加异步和同步多线程的支持
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
ALLOWED_HOSTS = ['*']
@ -42,11 +44,11 @@ INSTALLED_APPS = [
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'rest_framework',
'channels',
# 'daphne',
'django.contrib.staticfiles',
'corsheaders', # coreapi生成接口文档
'rest_framework',
'rest_framework.authtoken', # Token验证应用
'django_filters',
'update',
@ -85,7 +87,7 @@ TEMPLATES = [
WSGI_APPLICATION = 'dingxin_toolbox_drf.wsgi.application'
# 设置ASGI
ASGI_APPLICATION = 'dingxin_toolbox_drf.asgi.application'
ASGI_APPLICATION = 'dingxin_toolbox_drf.routing.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases

@ -16,16 +16,16 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import path, include
# from rest_framework.documentation import include_docs_urls
# from rest_framework.authtoken.views import obtain_auth_token
from rest_framework.documentation import include_docs_urls
from rest_framework.authtoken.views import obtain_auth_token
from update import consumers
urlpatterns = [
path('admin/', admin.site.urls),
# path('api-token-auth/', obtain_auth_token),
path('api-token-auth/', obtain_auth_token),
path('update/', include('update.urls')), # cinema Update 备注
path('', include('mock.urls')),
# path('docs/', include_docs_urls(title='接口文档')),
path('docs/', include_docs_urls(title='接口文档')),
]
websocket_urlpatterns = [

Loading…
Cancel
Save