1// This approach uses the Hono framework to set up routes for handling comments.
2// We will store comments in an SQLite database using the `std/sqlite` module for persistence.
3// The main route serves the HTML form and displays the comments.
4// The POST route handles new comment submissions.
21const app = new Hono();
22
23// Helper function to fetch all comments from the database
24async function fetchComments() {
25 const result = await sqlite.execute(`SELECT * FROM comments ORDER BY timestamp DESC`);
25 }
26
27 // Retrieve all comments from the database.
28 const { values: comments } = await sqlite.execute("SELECT content FROM comments");
29
3import { html } from "https://esm.town/v/stevekrouse/html?v=5";
4
5// Initialize SQLite database and comments table if it doesn't exist
6const initDB = async () => {
7 await sqlite.execute(`
57 const text = formData.text;
58
59 // Insert the comment into the database
60 await sqlite.execute("INSERT INTO comments (text) VALUES (?)", [text]);
61
1# VALL-E
2
3LLM code generation for vals! Make apps with a frontend, backend, and database.
4
5It's a bit of work to get this running, but it's worth it.
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
7It's currently super limited (no pagination, editing data, data-type specific viewers), and is just a couple dozens lines of code over a couple different vals. Forks encouraged! Just comment on the val if you add any features that you want to share.
8
9To use it on your own Val Town SQLite database, [fork it](https://www.val.town/v/stevekrouse/sqlite_admin/fork) to your account.
10
11It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/settings/api) as the password (leave the username field blank).
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable
1# Uptime Checker & Status Page
2
3This is a free, hackable uptime/downtime monitor that sends you an email when the site doesn't return a 200. It also stores historical uptime and latency data in your Val Town SQLite, which is used to power a status page. It supports multiple URLs in the same database and status page.
4
5## Installation
116 {
117 name: "Use Val Town SQLite to store data",
118 prompt: "Write a val that uses an SQLite database",
119 code: `import { sqlite } from "https://esm.town/v/std/sqlite?v=4";
120
30- [ ] add triggers to sidebar
31- [ ] add upload from SQL, CSV and JSON
32- [ ] add ability to connect to a non-val town Turso database
33- [x] fix wonky sidebar separator height problem (thanks to @stevekrouse)
34- [x] make result tables scrollable