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
/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
import { blob } from "https://esm.town/v/std/blob?v=11";
import { Hono } from "npm:hono@4.0.8";
import { HTTPException } from "npm:hono@4.0.8/http-exception";
const route = new Hono();
route.get("/:key", (c) => {
const key = c.req.param("key");
return c.render(
<form method="POST">
<label>Are you sure you want to delete {key} ?</label>
<input type="submit" value="Delete Blob" />
</form>,
);
});
route.post("/:key", async (c) => {
try {
await blob.delete(c.req.param("key"));
} catch (_) {
throw new HTTPException(500);
}
return c.redirect("/");
});
export default route;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
February 28, 2024