This repository has been archived on 2024-10-24. You can view files and clone it, but cannot push or open issues or pull requests.
NG_2022_Stanislav_Mykhailenko/Lesson_6/Task 1/templates/index.html

35 lines
869 B
HTML
Raw Normal View History

2023-01-06 21:35:22 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<title>Chat</title>
</head>
<body>
<form action="/send">
<label for="nickname">Nickname: </label><br>
<input type="text" id="nickname" name="nickname"><br>
<label for="message">Message: </label><br>
<textarea id="message" name="message" rows="5" cols="50"></textarea><br>
<button id="submit" type="submit">Submit</button>
</form>
Messages:
<hr>
<div id="messages">
{{messages|safe}}
</div>
<script>
function getMessages() {
const xhttp = new XMLHttpRequest();
xhttp.onload = function() {
document.getElementById("messages").innerHTML = this.responseText;
}
xhttp.open("GET", "/getMessagesTable", true);
xhttp.send();
}
window.setInterval(() => {
getMessages();
}, 1000);
</script>
</body>
</html>