Skip to content

Commit

Permalink
commit prod setup
Browse files Browse the repository at this point in the history
  • Loading branch information
josnin committed Nov 17, 2023
1 parent 6ba3fac commit d3c6523
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
5 changes: 1 addition & 4 deletions chat/templates/chat/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,8 @@
var tempDaysWeekdays = [];


let webSocketProtocol = location.protocol == 'https:' ? 'wss' : 'ws';

const chatSocket = new WebSocket(
`${webSocketProtocol}://${window.location.host}/ws/chat/${roomId}/`
);
const chatSocket = new WebSocket('{{WS_URL}}');

chatSocket.onmessage = function(e) {
const data = JSON.parse(e.data);
Expand Down
3 changes: 2 additions & 1 deletion chat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def room(request, group_id):
'participants': get_participants(group_obj=chatgroup, user=request.user.username),
'groups_participated': groups_participated,
'GIPHY_URL': settings.GIPHY_URL,
'API_KEY': settings.API_KEY
'API_KEY': settings.API_KEY,
'WS_URL': settings.WS_URL
})
else:
return HttpResponseRedirect(reverse("chat:unauthorized"))
Expand Down
5 changes: 5 additions & 0 deletions django_channel_tutorial/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

DEBUG = False

STATIC_URL = "/django-whatsapp-clone/static/"
MEDIA_URL = "/django-whatsapp-clone/media/"

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
Expand All @@ -34,3 +37,5 @@
},
},
}

WS_URL = "wss://demo.josnin.dev/django-whatsapp-clone/ws/chat"
5 changes: 5 additions & 0 deletions django_channel_tutorial/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'sslserver',
'channels',
'chat'
]
Expand Down Expand Up @@ -125,6 +126,8 @@
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'django_channel_tutorial/static')]

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

ASGI_APPLICATION = "django_channel_tutorial.routing.application"
CHANNEL_LAYERS = {
'default': {
Expand All @@ -148,3 +151,5 @@

GIPHY_URL = 'https://api.giphy.com/v1/gifs'
API_KEY = os.getenv('API_KEY')

WS_URL = "ws://127.0.0.1:8088/ws/chat"
14 changes: 14 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
aioredis==1.3.1
aiosqlite==0.15.0
anyio==3.7.1
asgiref==3.4.1
async-timeout==3.0.1
asyncpg==0.25.0
Expand All @@ -9,13 +10,19 @@ Automat==20.2.0
cffi==1.14.2
channels==3.0.4
channels-redis==3.2.0
click==8.1.7
constantly==15.1.0
cryptography==35.0.0
daphne==3.0.2
Django==3.2.13
django-sslserver==0.22
exceptiongroup==1.1.3
h11==0.14.0
hiredis==1.1.0
httptools==0.6.0
hyperlink==21.0.0
idna==2.10
importlib-metadata==6.7.0
incremental==21.3.0
iso8601==0.1.13
msgpack==1.0.0
Expand All @@ -29,11 +36,18 @@ pyOpenSSL==19.1.0
PyPika==0.42.1
python-dotenv==0.19.2
pytz==2020.1
PyYAML==6.0.1
service-identity==18.1.0
six==1.15.0
sniffio==1.3.0
sqlparse==0.3.1
tortoise-orm==0.16.16
Twisted==22.4.0
txaio==21.2.1
typing-extensions==3.7.4.3
uvicorn==0.22.0
uvloop==0.18.0
watchfiles==0.20.0
websockets==11.0.3
zipp==3.15.0
zope.interface==5.1.0

0 comments on commit d3c6523

Please sign in to comment.