adding validated services? patching forcad_local.py

This commit is contained in:
Your Name
2026-08-13 08:32:35 +07:00
parent d485f61169
commit e795614e45
1459 changed files with 420036 additions and 436 deletions

View File

@@ -0,0 +1,16 @@
<!doctype html>
<html>
<head>
<title>Bashist</title>
</head>
<body>
<h1>Welcome</h1>
<ul>
<li><a href="register.html">Register</a></li>
<li><a href="login.html">Login</a></li>
<li><a href="newpost.html">New Post</a></li>
<li><a href="posts.html">Public Posts</a></li>
<li><a href="userposts.html">My Posts</a></li>
</ul>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<!doctype html>
<html>
<head>
<title>Login</title>
</head>
<body>
<h1>Login</h1>
<form id="loginForm">
<input type="text" id="username" placeholder="Username" /><br />
<input type="password" id="password" placeholder="Password" /><br />
<button type="submit">Login</button>
</form>
<p id="msg"></p>
<script>
document
.getElementById("loginForm")
.addEventListener("submit", async (e) => {
e.preventDefault();
const res = await fetch("/api/user/login", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
username: document.getElementById("username").value,
password: document.getElementById("password").value,
}),
});
document.getElementById("msg").textContent = res.ok
? "Logged in! Cookie set."
: "Wrong username or password.";
});
</script>
</body>
</html>

View File

@@ -0,0 +1,36 @@
<!doctype html>
<html>
<head>
<title>New Post</title>
</head>
<body>
<h1>Create New Post</h1>
<form id="postForm">
<textarea id="content" placeholder="Write your post here..."></textarea
><br />
<label><input type="checkbox" id="private" /> Private</label><br />
<button type="submit">Submit</button>
</form>
<p id="msg"></p>
<script>
document
.getElementById("postForm")
.addEventListener("submit", async (e) => {
e.preventDefault();
const res = await fetch("/api/post/new", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
content: document.getElementById("content").value,
private: document.getElementById("private").checked,
}),
});
document.getElementById("msg").textContent = res.ok
? "Post created!"
: "Error creating post (maybe not logged in?)";
});
</script>
</body>
</html>

View File

@@ -0,0 +1,26 @@
<!doctype html>
<html>
<head>
<title>Public Posts</title>
</head>
<body>
<h1>Public Posts</h1>
<button onclick="loadPosts()">Refresh</button>
<ul id="posts"></ul>
<script>
async function loadPosts() {
const res = await fetch("/api/posts");
const data = await res.json();
const list = document.getElementById("posts");
list.innerHTML = "";
data.forEach((post) => {
const li = document.createElement("li");
li.textContent = post.username + ": " + post.content;
list.appendChild(li);
});
}
loadPosts();
</script>
</body>
</html>

View File

@@ -0,0 +1,35 @@
<!doctype html>
<html>
<head>
<title>Register</title>
</head>
<body>
<h1>Register</h1>
<form id="registerForm">
<input type="text" id="username" placeholder="Username" /><br />
<input type="password" id="password" placeholder="Password" /><br />
<button type="submit">Register</button>
</form>
<p id="msg"></p>
<script>
document
.getElementById("registerForm")
.addEventListener("submit", async (e) => {
e.preventDefault();
const res = await fetch("/api/user/register", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
username: document.getElementById("username").value,
password: document.getElementById("password").value,
}),
});
document.getElementById("msg").textContent = res.ok
? "Registered! Cookie set."
: "Error registering.";
});
</script>
</body>
</html>

View File

@@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<title>My Posts</title>
</head>
<body>
<h1>My Posts</h1>
<button onclick="loadUserPosts()">Refresh</button>
<ul id="posts"></ul>
<script>
async function loadUserPosts() {
const res = await fetch("/api/user/posts");
if (!res.ok) {
document.getElementById("posts").innerHTML =
"<li>Error: Not logged in</li>";
return;
}
const data = await res.json();
const list = document.getElementById("posts");
list.innerHTML = "";
data.forEach((post) => {
const li = document.createElement("li");
li.textContent = post.content;
list.appendChild(li);
});
}
loadUserPosts();
</script>
</body>
</html>