layer7-web-2/templates/index.html
2026-08-13 01:03:34 +09:00

47 lines
1.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>wow 게시판</title>
</head>
<body>
<h1>wow 게시판</h1>
<a href="/register">Register</a>
<a href="/login">Login</a>
<form action="/post" method="POST">
<input placeholder="title" name="title" />
<textarea placeholder="content" name="content"></textarea>
<button type="submit">Submit</button>
</form>
<form action="/" method="GET">
<input placeholder="search" name="q" />
<button type="submit">Search</button>
</form>
<div id="posts">
{% for post in posts %}
<a href="/post/{{ post.id }}">
<div class="post">
<h2>{{ post.title }}</h2>
<p>{{ post.content }}</p>
<a href="/edit/{{ post.id }}">Edit</a>
<a href="#" onclick="deletePost(`{{ post.id }}`)">Delete</a>
<hr />
</div>
</a>
{% endfor %}
</div>
<script>
function deletePost(postId) {
fetch(`/post/${postId}`, {
method: "DELETE",
})
.then(() => {
location.reload();
});
}
</script>
</body>
</html>