initial commit. Go test app

This commit is contained in:
2026-05-04 16:38:32 +02:00
parent e50565bf85
commit e1a58e92a8
7 changed files with 329 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
package main
templ Page(tasks []Task) {
<!DOCTYPE html>
<html>
<head>
<title>Homelab Go Tasks</title>
<script src="https://unpkg.com/htmx.org@2.0.0"></script>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100 p-10">
<div class="max-w-md mx-auto bg-white p-6 rounded shadow">
<h1 class="text-2xl font-bold mb-4">My Tasks</h1>
<!-- Form uses HTMX to post to /tasks and swap the list -->
<form hx-post="/tasks" hx-target="#task-list" hx-swap="outerHTML" class="mb-4 flex gap-2">
<input type="text" name="title" class="border p-2 flex-grow" placeholder="New task..." required />
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded">Add</button>
</form>
@TaskList(tasks)
</div>
</body>
</html>
}
templ TaskList(tasks []Task) {
<ul id="task-list" class="space-y-2">
for _, task := range tasks {
<li class="p-2 border-b"> { task.Title } </li>
}
</ul>
}