forked from cookiecutter/cookiecutter-django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pydanny#2506' into next
- Loading branch information
Showing
12 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
ASGI config for {{ cookiecutter.project_name }} project. | ||
It exposes the ASGI callable as a module-level variable named ``application``. | ||
For more information on this file, see | ||
https://docs.djangoproject.com/en/dev/howto/deployment/asgi/ | ||
""" | ||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
# This allows easy placement of apps within the interior | ||
# {{ cookiecutter.project_slug }} directory. | ||
app_path = Path(__file__).parents[1].resolve() | ||
sys.path.append(str(app_path / "{{ cookiecutter.project_slug }}")) | ||
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks | ||
# if running multiple sites in the same mod_wsgi process. To fix this, use | ||
# mod_wsgi daemon mode with each site in its own daemon process, or use | ||
# os.environ["DJANGO_SETTINGS_MODULE"] = "config.settings.production" | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production") | ||
|
||
# This application object is used by any ASGI server configured to use this | ||
# file. This includes Django's development server, if the ASGI_APPLICATION | ||
# setting points here. | ||
django_application = get_asgi_application() | ||
# Apply ASGI middleware here. | ||
# from helloworld.asgi import HelloWorldApplication | ||
# application = HelloWorldApplication(application) | ||
|
||
# Import websocket application here, so apps from django_application are loaded first | ||
from .websocket import websocket_application # noqa isort:skip | ||
|
||
|
||
async def application(scope, receive, send): | ||
if scope["type"] == "http": | ||
await django_application(scope, receive, send) | ||
elif scope["type"] == "websocket": | ||
await websocket_application(scope, receive, send) | ||
else: | ||
raise NotImplementedError(f"Unknown scope type {scope['type']}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
async def websocket_application(scope, receive, send): | ||
while True: | ||
event = await receive() | ||
|
||
if event["type"] == "websocket.connect": | ||
await send({"type": "websocket.accept"}) | ||
|
||
if event["type"] == "websocket.disconnect": | ||
break | ||
|
||
if event["type"] == "websocket.receive": | ||
if event["text"] == "ping": | ||
await send({"type": "websocket.send", "text": "pong!"}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters