Загрузить файлы в «z1/templates»
This commit is contained in:
parent
a4514b0ab6
commit
f05064563a
52
z1/templates/index.html
Normal file
52
z1/templates/index.html
Normal file
@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="sk">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Správa používateľov</title>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Zoznam používateľov</h1>
|
||||
<ul id="user-list">
|
||||
{% for user in users %}
|
||||
<li>
|
||||
{{ user[1] }}
|
||||
<button class="delete-btn" onclick="deleteUser('{{ user[0] }}')">Odstrániť</button>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
<h2>Pridať používateľa</h2>
|
||||
<input type="text" id="username" placeholder="Zadajte meno">
|
||||
<button onclick="addUser()">Pridať</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function addUser() {
|
||||
const name = document.getElementById("username").value;
|
||||
if (!name) {
|
||||
alert("Zadajte meno!");
|
||||
return;
|
||||
}
|
||||
fetch("/add_user", {
|
||||
method: "POST",
|
||||
body: new URLSearchParams({ name }),
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(() => location.reload());
|
||||
}
|
||||
|
||||
function deleteUser(id) {
|
||||
fetch(`/delete_user/${id}`, { method: "POST" })
|
||||
.then(response => response.json())
|
||||
.then(() => location.reload());
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user