Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { sqlite } from "https://esm.town/v/std/sqlite";
import { Hono } from "npm:hono@3";
await sqlite.execute(`create table if not exists kv(
key text unique,
value text
)`);
const app = new Hono();
app.get("/", async (c) => {
let res = await sqlite.execute(`select key, value from kv`);
return c.json(res);
});
app.post("/", async function(c) {
let res = await sqlite.execute({
sql: `insert into kv(key, value) values (:key, :value)`,
args: { key: "specialkey", value: "specialvalue" },
});
return c.json(res);
});
export default app.fetch;
brianleroux-key_value_api.web.val.run
April 11, 2024