Global Chat
This commit is contained in:
24
frontend/templates/chat.html
Normal file
24
frontend/templates/chat.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>Chat</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Chat</h1>
|
||||
|
||||
<form id="form">
|
||||
<input type="text" name="message" />
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
let url = `ws://${window.location.host}/ws/socket-server/`
|
||||
|
||||
const chatSocket = new WebSocket(url)
|
||||
chatSocket.onmessage = function(e){
|
||||
let data = JSON.parse(e.data)
|
||||
console.log('Data:', data)
|
||||
}
|
||||
|
||||
</script>
|
||||
</b
|
@ -12,6 +12,7 @@
|
||||
<a href="/" class="nav__link" data-link>Dashboard</a>
|
||||
<a href="/posts" class="nav__link" data-link>Posts</a>
|
||||
<a href="/settings" class="nav__link" data-link>Settings</a>
|
||||
<a href="/chat" class="nav__link" data-link>Chat</a>
|
||||
</nav>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="{% static 'js/index.js' %}"></script>
|
||||
|
Reference in New Issue
Block a user