mirror of
https://github.com/evgen-app/chess_rpg_backend.git
synced 2024-11-22 01:27:00 +03:00
Added daphne support
This commit is contained in:
parent
e70360a1af
commit
4fd016f603
|
@ -16,7 +16,7 @@ $ docker run -p 6379:6379 -d redis:5
|
|||
|
||||
### run
|
||||
```shell
|
||||
$ python3 manage.py runserver 0.0.0.0:8000
|
||||
$ daphne -b 0.0.0.0 -p 8000 chess_backend.asgi:application
|
||||
```
|
||||
|
||||
### Описание команд сокетов
|
||||
|
|
|
@ -11,10 +11,14 @@ DEBUG = True
|
|||
|
||||
ALLOWED_HOSTS = []
|
||||
|
||||
if DEBUG:
|
||||
ALLOWED_HOSTS = ["*"]
|
||||
|
||||
INSTALLED_APPS = [
|
||||
"django.contrib.sessions",
|
||||
"django.contrib.auth",
|
||||
"django.contrib.contenttypes",
|
||||
"django.contrib.staticfiles",
|
||||
"django.contrib.messages",
|
||||
# Packages
|
||||
"rest_framework",
|
||||
|
@ -25,10 +29,26 @@ INSTALLED_APPS = [
|
|||
]
|
||||
|
||||
if DEBUG:
|
||||
INSTALLED_APPS.append("django.contrib.staticfiles")
|
||||
INSTALLED_APPS.append("drf_yasg")
|
||||
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
MIDDLEWARE = [
|
||||
"django.middleware.security.SecurityMiddleware",
|
||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||
|
|
|
@ -22,8 +22,10 @@ schema_view = get_schema_view(
|
|||
permission_classes=(permissions.AllowAny,),
|
||||
)
|
||||
|
||||
urlpatterns = [path("api/", include("game.urls"))] + static(
|
||||
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT
|
||||
urlpatterns = (
|
||||
[path("api/", include("game.urls"))]
|
||||
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
)
|
||||
|
||||
if settings.DEBUG:
|
||||
|
@ -43,4 +45,4 @@ if settings.DEBUG:
|
|||
schema_view.with_ui("redoc", cache_timeout=0),
|
||||
name="schema-redoc",
|
||||
),
|
||||
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
|
||||
]
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
import json
|
||||
import os
|
||||
import django
|
||||
|
||||
from asgiref.sync import sync_to_async
|
||||
from channels.generic.websocket import AsyncWebsocketConsumer
|
||||
from channels.layers import get_channel_layer
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chess_backend.settings")
|
||||
django.setup()
|
||||
|
||||
from game.models import Deck
|
||||
from room.models import PlayerInQueue, Room, PlayerInRoom, GameState
|
||||
from room.services.room_create import create_room
|
||||
|
|
Loading…
Reference in New Issue
Block a user