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
Stanislav Mykhailenko ef62307e08
Add Lesson 6 Task 1
2023-01-06 23:35:22 +02:00

34 lines
869 B
HTML

<!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>