Added channels, api paths and configured protocol routing
This commit is contained in:
parent
a4db6261a9
commit
38adc358c8
6 changed files with 34 additions and 17 deletions
Binary file not shown.
|
|
@ -1,8 +1,16 @@
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
|
||||||
|
from apps.domains.viewsets import DomainViewSet, OrganisationViewSet, DatasetViewSet
|
||||||
from apps.users.viewsets import UserViewSet
|
from apps.users.viewsets import UserViewSet
|
||||||
|
from apps.agents.viewsets import AgentViewSet, AgentExecutionViewSet
|
||||||
|
from apps.users.urls import urlpatterns as user_urls
|
||||||
|
|
||||||
router = DefaultRouter()
|
router = DefaultRouter()
|
||||||
router.register(r'users', UserViewSet, basename = 'user')
|
router.register(r'domain', DomainViewSet, basename = 'domain')
|
||||||
|
router.register(r'organisation', OrganisationViewSet, basename = 'organisation')
|
||||||
|
router.register(r'dataset', DatasetViewSet, basename = 'dataset')
|
||||||
|
router.register(r'user', UserViewSet, basename = 'user')
|
||||||
|
router.register(r'agent', AgentViewSet, basename = 'agent')
|
||||||
|
router.register(r'agent-execution', AgentExecutionViewSet, basename = 'agent-execution')
|
||||||
|
|
||||||
urlpatterns = router.urls
|
urlpatterns = user_urls + router.urls
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,20 @@
|
||||||
import os
|
import os
|
||||||
|
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||||
|
from channels.auth import AuthMiddlewareStack
|
||||||
|
from channels.security.websocket import AllowedHostsOriginValidator
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||||
|
|
||||||
application = get_asgi_application()
|
django_asgi_app = get_asgi_application()
|
||||||
|
|
||||||
|
from apps.agents.routing import websocket_urlpatterns
|
||||||
|
|
||||||
|
application = ProtocolTypeRouter({
|
||||||
|
"http": django_asgi_app,
|
||||||
|
"websocket": AllowedHostsOriginValidator(
|
||||||
|
AuthMiddlewareStack(
|
||||||
|
URLRouter(websocket_urlpatterns)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ load_dotenv(dotenv_path = BASE_DIR / '.env')
|
||||||
|
|
||||||
BUILD_DIR = os.getenv('DJANGO_BUILD_DIR', BASE_DIR / 'build')
|
BUILD_DIR = os.getenv('DJANGO_BUILD_DIR', BASE_DIR / 'build')
|
||||||
|
|
||||||
|
|
||||||
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
|
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
|
||||||
DEBUG = str(os.getenv('DJANGO_DEBUG')).lower() in ('1', 'true', 'yes', 'on')
|
DEBUG = str(os.getenv('DJANGO_DEBUG')).lower() in ('1', 'true', 'yes', 'on')
|
||||||
|
|
||||||
|
|
@ -23,6 +22,7 @@ MEDIA_ROOT = os.getenv('DJANGO_MEDIA_ROOT', BASE_DIR / 'media')
|
||||||
|
|
||||||
OVERRIDE_APPS = [
|
OVERRIDE_APPS = [
|
||||||
'jazzmin',
|
'jazzmin',
|
||||||
|
'daphne',
|
||||||
]
|
]
|
||||||
DJANGO_APPS = [
|
DJANGO_APPS = [
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
|
|
@ -34,6 +34,7 @@ DJANGO_APPS = [
|
||||||
]
|
]
|
||||||
THIRD_PARTY_APPS = [
|
THIRD_PARTY_APPS = [
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
|
'channels',
|
||||||
]
|
]
|
||||||
LOCAL_APPS = [
|
LOCAL_APPS = [
|
||||||
'apps.users',
|
'apps.users',
|
||||||
|
|
@ -42,7 +43,6 @@ LOCAL_APPS = [
|
||||||
]
|
]
|
||||||
INSTALLED_APPS = OVERRIDE_APPS + DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
INSTALLED_APPS = OVERRIDE_APPS + DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS
|
||||||
|
|
||||||
|
|
||||||
AUTH_USER_MODEL = 'users.User'
|
AUTH_USER_MODEL = 'users.User'
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
|
@ -61,6 +61,11 @@ ROOT_URLCONF = f'{PARENT_NAME}.urls'
|
||||||
WSGI_APPLICATION = f'{PARENT_NAME}.wsgi.application'
|
WSGI_APPLICATION = f'{PARENT_NAME}.wsgi.application'
|
||||||
ASGI_APPLICATION = f'{PARENT_NAME}.asgi.application'
|
ASGI_APPLICATION = f'{PARENT_NAME}.asgi.application'
|
||||||
|
|
||||||
|
CHANNEL_LAYERS = {
|
||||||
|
'default': {
|
||||||
|
'BACKEND': 'channels.layers.InMemoryChannelLayer'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,5 @@
|
||||||
"""
|
|
||||||
WSGI config for config 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/5.2/howto/deployment/wsgi/
|
|
||||||
"""
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from django.core.wsgi import get_wsgi_application
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||||
|
|
||||||
application = get_wsgi_application()
|
application = get_wsgi_application()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
asgiref==3.10.0
|
asgiref==3.10.0
|
||||||
|
celery==5.6.0
|
||||||
django==5.2.8
|
django==5.2.8
|
||||||
djangorestframework==3.16.1
|
djangorestframework==3.16.1
|
||||||
|
channels[daphne]==4.3.0
|
||||||
django-jazzmin==3.0.1
|
django-jazzmin==3.0.1
|
||||||
gunicorn==23.0.0
|
gunicorn==23.0.0
|
||||||
jinja2==3.1.6
|
jinja2==3.1.6
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue