1import { fetch } from "https://esm.town/v/std/fetch";
2import process from "node:process";
3
17 }
18
19 const resp = await fetch("https://api.pushover.net/1/messages.json", {
20 headers: {
21 "Content-Type": "application/json",
9app.get("/", async (c) => c.html(await sqlite_admin_tables()));
10app.get("/:table", async (c) => c.html(await sqlite_admin_table(c.req.param("table"))));
11export default basicAuth(app.fetch);
11
12 constructor() {}
13 async fetch(req: Request): Promise<Response> {
14 if (new URL(req.url).pathname === "/robots.txt") {
15 return new Response("User-agent: *\nDisallow: /");
232const sc = new StaticChess();
233
234export default analyticsHandlerWrapper(sc.fetch.bind(sc));
1import { type WriterOptions } from "https://esm.town/v/nbbaier/WriterOptions";
2import { fetch } from "https://esm.town/v/std/fetch?v=4";
3import OpenAI, { type ClientOptions } from "npm:openai";
4
32 private async getVal(username: string, valName: string) {
33 try {
34 const res = await fetch(`https://api.val.town/v1/alias/${username}/${valName}`, {
35 method: "GET",
36 headers: {
72 private async updateReadme(id: string, readme: string) {
73 try {
74 const res = await fetch(`https://api.val.town/v1/vals/${id}`, {
75 method: "PUT",
76 headers: {
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
1import { Hono } from "npm:hono@3";
2import { cors } from "npm:hono/cors";
3import { fetch } from "https://esm.town/v/std/fetch";
4
5const app = new Hono();
10// PubMed search function (modified to accept more parameters)
11async function pubmedSearch(query, userId, additionalParams = {}) {
12 const url = 'https://www.pubmedisearch.com/api/fetch_articles';
13 const options = {
14 method: 'POST',
30
31 try {
32 const response = await fetch(url, options);
33 if (!response.ok) {
34 throw new Error(`HTTP error! status: ${response.status}`);
79});
80
81export default app.fetch;
82export { pubmedSearch };
88});
89
90export default app.fetch;
69 );
70 });
71 export default app.fetch;`,
72 },
73 {
129 {
130 prompt: "Write a val that accesses environment variables",
131 code: `const res = await fetch("${API_URL}/v1/me", {
132 headers: {
133 Authorization: \`Bearer \${Deno.env.get("valtown")}\`,
141 code: `import process from "node:process";
142
143 const res = await fetch("${API_URL}/v1/me", {
144 headers: {
145 Authorization: \`Bearer \${process.env.valtown}\`,
165 code: `import cheerio from "npm:cheerio";
166
167 const response = await fetch("https://example.com");
168 const body = await response.text();
169 const $ = cheerio.load(body);
453 {
454 role: "user",
455 content: "Write a val that fetches the weather in Brooklyn, NY",
456 },
457 {
458 role: "assistant",
459 content:
460 "```ts\nexport default async function(req: Request): Promise<Response> {\n const apiKey = Deno.env.get(\"METEO_KEY\");\n const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m¤t_weather=true&apikey=${apiKey}`;\n\n const response = await fetch(apiUrl);\n const weatherData = await response.json();\n\n return new Response(JSON.stringify(weatherData), { headers: { \"Content-Type\": \"application/json\" } });\n}\n```",
461 },
462 {
467 role: "assistant",
468 content:
469 "```ts\n/** @jsxImportSource npm:hono@3/jsx */\nimport { Hono } from \"npm:hono\";\n\nconst app = new Hono();\napp.get(\"/\", async (c) => {\n return c.html(\n <div>\n <form>\n Your name: <input type=\"text\" name=\"name\" /> <input type=\"submit\" />\n </form>\n Hello {c.req.query(\"name\")}\n </div>,\n );\n});\nexport default app.fetch;\n```",
470 },
471 ...templatePrompts,
1/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
5import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
133});
134
135export default modifyFetchHandler(passwordAuth(app.fetch));
2import { updateValByName } from "https://esm.town/v/nbbaier/updateValByName?v=14";
3import { basicAuth } from "https://esm.town/v/pomdtr/basicAuth?v=62";
4import { fetchText } from "https://esm.town/v/stevekrouse/fetchText";
5import { chat } from "https://esm.town/v/stevekrouse/openai";
6import cronstrue from "npm:cronstrue";
19It stores each line of the poem in sqlite.
20It has a textbox that lets anyone input a new line to the poem.`,
21 content: await fetchText("https://esm.town/v/stevekrouse/poembuilder3?v=4"),
22 },
23 {
24 user: "an app that uses chatgpt to convert natural language to cron syntax",
25 content: await fetchText("https://esm.town/v/stevekrouse/cron2"),
26 },
27];
29const app = new Hono();
30
31export default basicAuth(app.fetch);
32app.get("/", async (c) => {
33 const example = examples[Math.floor(Math.random() * examples.length)];
98 Write ONLY Deno TypeScript.
99
100 If you use Hono, use \`export default app.fetch;\` to start the server.
101
102 Only use web standard fetch.
103 // Our library for SQLite
104 import { sqlite } from "https://esm.town/v/std/sqlite";