Compare commits
1 Commits
deploy/awi
...
main
Author | SHA1 | Date |
---|---|---|
Daniel Perelman | b30982bd7e |
|
@ -1,7 +1,12 @@
|
|||
from channels.http import AsgiHandler
|
||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
||||
|
||||
import django
|
||||
from django.conf.urls import url
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
# TODO Importing views breaks if django.setup() isn't called first...
|
||||
# ... but this isn't the way this is supposed to work.
|
||||
django.setup()
|
||||
|
||||
from . import views
|
||||
|
||||
|
@ -9,8 +14,8 @@ application = ProtocolTypeRouter({
|
|||
"http": URLRouter([
|
||||
url(r'^(?P<access_code>[a-zA-Z]{6})/', URLRouter([
|
||||
url(r"status/(?P<hashcode>[a-z0-9]{64})/",
|
||||
views.StatusLongPollConsumer, name='status'),
|
||||
views.StatusLongPollConsumer.as_asgi(), name='status'),
|
||||
])),
|
||||
url(r"", AsgiHandler),
|
||||
url(r"", get_asgi_application()),
|
||||
]),
|
||||
})
|
||||
|
|
|
@ -377,7 +377,7 @@ class StatusLongPollConsumer(AsyncHttpConsumer):
|
|||
|
||||
async def fear_tracker_hashcode_seen(self, event):
|
||||
if self.hashcode != event["hashcode"]:
|
||||
if event["status_string"]:
|
||||
if "status_string" in event and event["status_string"]:
|
||||
body = event["status_string"].encode('utf-8')
|
||||
await self.send_response(200, body)
|
||||
await self.disconnect()
|
||||
|
|
|
@ -3,10 +3,9 @@ ASGI entrypoint. Configures Django and then runs the application
|
|||
defined in the ASGI_APPLICATION setting.
|
||||
"""
|
||||
|
||||
import os
|
||||
import django
|
||||
from channels.routing import get_default_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "fear_tracker_site.settings")
|
||||
import fear_tracker.routing
|
||||
|
||||
django.setup()
|
||||
application = get_default_application()
|
||||
application = fear_tracker.routing.application
|
||||
|
|
Loading…
Reference in New Issue