13 const readmeVals: any = await (await fetch("https://janpaul123-readmevals.web.val.run/")).json();
14
15 const API_URL = "https://api.val.town";
16
17 const sections = [
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}\`,
310 You can attach files to your emails by using the \`attachments\` field.
311 Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
312 which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
313 method is doing in this example:
314
412 \`\`\`
413
414 ### Lower-level API
415
416 We do provide access to the lower-level getter and setters, which are useful if you are storing non-JSON or binary data, need to stream in your response or request data, or do anything else lower-level.
417
418 - \`async get(key: string)\`: Retrieves a blob for a given key.
419 - \`async set(key: string, value: string | BodyInit)\`: Sets the blob value for a given key. See [BodyInit](https://deno.land/api@v1.38.1?s=BodyInit).
420
421 ### Limitations
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 {
1* Fork this val to your own profile.
2* Create a [Val Town API token](https://www.val.town/settings/api), open the browser preview of this val, and use the API token as the password to log in.
3
14 }
15
16 const response = await fetch(`https://api.github.com/users/${userName}/events`);
17 const events = await response.json();
18
1// This val creates a simple web interface for opening the Val Town office door.
2// It uses the Hono framework for routing and HTML rendering, and interacts with
3// the SwitchBot API to control the door. The approach includes:
4// 1. A frontend route that displays a button to open the door
5// 2. A backend route that handles the door opening request
6// 3. Integration with SwitchBot API for door control
7// 4. Basic error handling and email notification on failure
8
29 .toString("base64");
30
31 const response = await fetch(`https://api.switch-bot.com/${path}`, {
32 headers: {
33 "Authorization": token,
1// This val creates a simple web interface for opening the Val Town office door.
2// It uses the Hono framework for routing and HTML rendering, and interacts with
3// the SwitchBot API to control the door. The approach includes:
4// 1. A frontend route that displays a button to open the door
5// 2. A backend route that handles the door opening request
6// 3. Integration with SwitchBot API for door control
7// 4. Basic error handling and email notification on failure
8
29 .toString("base64");
30
31 const response = await fetch(`https://api.switch-bot.com/${path}`, {
32 headers: {
33 "Authorization": token,
15## Response Structure
16
17The API returns a JSON response body with the following structure:
18
19```json
131
132const boardToEndpoint = (board: string) => {
133 return board.replace(/\.json$/, ".api/run");
134};
135
4
5For now, requires you to be running a board server. This harness actually acts
6as a proxy to the board server [run API endpoint](https://breadboard-ai.github.io/breadboard/docs/reference/board-run-api-endpoint/),
7and puts a nice (well, somewhat nice) frontend on top of it.
8
11
12The script will look for the `BB_LIVE_KEY` in your Val Town environment, which
13must contain your board server API key.
14
15To use, create an HTTP val, then import the `proxy` function from this script and call it like this:
2
3const airtable = new Airtable({
4 apiKey: Deno.env.get("airtable_pat"),
5 baseId: "app0TOKIOXvF3zoS2",
6 tableName: "tblRJj6ty16uR9QhC",
11 const results = [];
12 const metaResponse = await fetch(
13 `https://cool-proxy.koyeb.app/hdiuhmalkmc9d0ck7UCFVGBJHN?destination=https://api.malsync.moe/mal/anime/${id}`,
14 );
15 const metaData = await metaResponse.json();
22 const episodeIdentifier = `${data.identifier}-episode-${ep}`;
23 return [
24 fetch(`https://animetize-api.vercel.app/servers/${episodeIdentifier}`),
25 fetch(`https://animetize-api.vercel.app/watch/${episodeIdentifier}`),
26 ];
27 }
67 <title>${metaData.title}</title>
68 <style>
69 @import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;700&display=swap');
70
71 html,
159 const results = [];
160 const metaResponse = await fetch(
161 `https://cool-proxy.koyeb.app/hdiuhmalkmc9d0ck7UCFVGBJHN?destination=https://api.malsync.moe/mal/anime/${id}`,
162 );
163 const metaData = await metaResponse.json();
169 const episodeIdentifier = `${data.identifier}-episode-${ep}`;
170 return [
171 fetch(`https://animetize-api.vercel.app/servers/${episodeIdentifier}`),
172 fetch(`https://animetize-api.vercel.app/watch/${episodeIdentifier}`),
173 ];
174 }
217 <body style="background:#111;color:#DDD;">
218 <h1>Tempguy-Anime</h1>
219 <pre>https://tempguy-anime.web.val.run/api/MAL_ID/EPISODE/(sub/dub)</pre>
220 <pre>https://tempguy-anime.web.val.run/api/21/1/dub</pre>
221 </body>,
222 );