Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

PriestGPT Client

Client for https://www.val.town/v/mjweaver01/PriestGPT

Ask him about books or verses in the bible, and he will be sure to give you a short sermon about it!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/** @jsxImportSource https://esm.sh/hono/jsx */
import { fetch } from "https://esm.town/v/std/fetch";
import { Hono } from "npm:hono";
const app = new Hono();
app.get("/", (c) => {
return c.render(
`<html>
<head>
<title>PriestGPT</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-4 max-w-lg mx-auto">
<h1 class="text-3xl font-bold mb-4">
PriestGPT
</h1>
<p class="mb-4">Client for the <a class="underline" href="https://www.val.town/v/mjweaver01/PriestGPT">PriestGPT API</a></p>
<p class="mb-4">Ask him about books or verses in the bible, and he will be sure to give you a short sermon about it!</p>
<input
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:f
placeholder="What verse would you like to discuss today?"
/>
</body>
<script>
document.querySelector("input").addEventListener("keyup", (e) => {
// if enter is pressed, submit the form
if (e.key === 'Enter' || e.keyCode === 13) {
e.preventDefault();
document.querySelector("input").disabled = true;
const v = document.querySelector("input").value
window.location.href = "/" + encodeURIComponent(v);
document.querySelector("input").value = 'Asking about \"' + v + '\"...';
}
})
</script>
</html>`,
);
});
app.get("/:verse", async (c) => {
const verse = c.req.param("verse");
// https://www.val.town/v/mjweaver01/PriestGPT
const answer = await fetch(`https://mjweaver01-priestgpt.web.val.run/ask/${encodeURI(verse)}`).then(
(res) => res.text(),
);
return c.render(
`<html>
<head>
<title>PriestGPT</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="p-4 max-w-lg mx-auto">
<h1 class="text-3xl font-bold mb-4">
PriestGPT
</h1>
<h2 class="text-2xl font-bold mb-4">
On "${verse}", Father says...
</h2>
<p style="word-wrap: break-word; white-space: pre-wrap;">${answer}</p>
</body>
</html>`,
);
});
export default app.fetch;
mjweaver01-priestgptclient.web.val.run
April 18, 2024