File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,9 @@ async def connect(self):
3838 self .channel_name ,
3939 )
4040
41+ await self .accept ()
42+ await self .send (text_data = f'<p id="foo">site name: { site .name } </p>' )
43+
4144 @asynccontextmanager
4245 async def close_on_error (
4346 self , error : type [BaseException ] | tuple [BaseException , ...] = Exception
Original file line number Diff line number Diff line change 1212from channels .routing import ProtocolTypeRouter , URLRouter
1313from channels .security .websocket import AllowedHostsOriginValidator
1414from django .core .asgi import get_asgi_application
15- from django .urls import include
15+
16+ from director .apps .sites .consumers import urlpatterns as sites_urlpatterns
1617
1718os .environ .setdefault ("DJANGO_SETTINGS_MODULE" , "director.settings" )
1819
2324application = ProtocolTypeRouter (
2425 {
2526 "http" : django_asgi_app ,
26- "websocket" : AllowedHostsOriginValidator (
27- AuthMiddlewareStack (URLRouter ([* include ("director.apps.sites.consumers" )]))
28- ),
27+ "websocket" : AllowedHostsOriginValidator (AuthMiddlewareStack (URLRouter (sites_urlpatterns ))),
2928 }
3029)
Original file line number Diff line number Diff line change 44 {{ block.super }}
55
66 < script src ="https://unpkg.com/htmx-ext-ws@2.0.2 "
7- integrity ="sha384-vuKxTKv5TX/b3lLzDKP2U363sOAoRo5wSvzzc3LJsbaQRSBSS+3rKKHcOx5J8doU " crossorigin ="anonymous "> </ script >
7+ integrity ="sha384-932iIqjARv+Gy0+r6RTGrfCkCKS5MsF539Iqf6Vt8L4YmbnnWI2DSFoMD90bvXd0 " crossorigin ="anonymous "> </ script >
88{% endblock head %}
99
1010{% block main %}
11- < h1 class ="p-2 text-large "> {{ site.name }}</ h1 >
12- < div hx-ext ="ws " ws-connect ="{% url '' %} ">
13-
11+ <!-- <h1 class="p-2 text-large">{{ site.name }}</h1> -->
12+ < div hx-ext ="ws " ws-connect ="/sites/{{ site.id }}/ "
13+ class ="p-2 mb-4 " hx-swap-oob ='true '>
14+ < p id ="foo "> </ p >
1415 </ div >
16+ {% comment %}
1517 < button htmx-post ="{% url 'sites:clear' site.id %} "
1618 hx-target ="{% url 'sites:clear_operations' %} "
1719 class ="dt-btn-primary ">
1820
1921 {% heroicon_outline "trash" stroke_width="0.8" size="24" class="mr-2" %}
2022 < p > Clear Operations</ p >
2123 </ button >
24+ {% endcomment %}
2225{% endblock main %}
You can’t perform that action at this time.
0 commit comments