init
This commit is contained in:
commit
5cc0525481
8 changed files with 116 additions and 0 deletions
62
templates/index.html
Normal file
62
templates/index.html
Normal file
|
@ -0,0 +1,62 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<script>
|
||||
let notesdiv;
|
||||
|
||||
function buttonclick() {
|
||||
fetch("/note",{
|
||||
method:"POST",
|
||||
body: JSON.stringify(notizinput.value),
|
||||
headers: {"Content-type":"application/json; charset=UTF-8"}
|
||||
});
|
||||
notizinput.value = "";
|
||||
getnotes()
|
||||
};
|
||||
|
||||
function getnotes() {
|
||||
notesdiv.innerHTML = "";
|
||||
fetch("/note", { method: "GET" })
|
||||
.then(response => response.json())
|
||||
.then(notesarray => {
|
||||
console.log(notesarray);
|
||||
for (let note of notesarray) {
|
||||
console.log(note);
|
||||
notesdiv.innerHTML += `
|
||||
<div class="note">
|
||||
<p>${note}</p>
|
||||
</div>`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function initstuff() {
|
||||
notesdiv = document.getElementById("notes");
|
||||
getnotes();
|
||||
//setInterval(getnotes,10000)
|
||||
}
|
||||
|
||||
function handleKeyPress(event) {
|
||||
if (event.key === "Enter") { // Überprüfen, ob die Enter-Taste gedrückt wurde
|
||||
buttonclick();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window.onload = initstuff;
|
||||
</script>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Api Test</title>
|
||||
</head>
|
||||
<body id="body">
|
||||
<h1>Notizen</h1>
|
||||
<div onsubmit="" style="padding-bottom: 10px;" id="notizform">
|
||||
<input onkeydown="handleKeyPress(event)" type="text" class="input" id="notizinput">
|
||||
<button onclick="buttonclick()" class="button">hinzufügen</button>
|
||||
</div>
|
||||
<div id="notes"></div>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue