54You can attach files to your emails by using the `attachments` field.
55Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
56which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
57method is doing in this example:
58
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { parseSendGridEmail } from "https://esm.town/v/stevekrouse/parseSendGridEmail?v=8";
3import { parseSendGridEmails } from "https://esm.town/v/stevekrouse/parseSendGridEmails?v=10";
69}) => {
70let result = await fetch(
71`${API_URL}/v1/email`,
72{
73method: "POST",
fancyPlumSquirrelmain.tsx2 matches
1/**
2* This val creates an elegant and professional web app for managing panel members for the State Street discussion.
3* It uses React for the UI, SQLite for storing panel member information, and the Fetch API to communicate with the server.
4* The design is clean and sophisticated, with a muted color palette and subtle animations.
5*/
182183const css = `
184@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Roboto:wght@300;400;700&display=swap');
185186:root {
egoBoostermain.tsx2 matches
2* This ego booster app takes a selfie, sends it to GPT-4o-mini for analysis,
3* and streams funny, specific compliments about the user's appearance.
4* We use the WebRTC API for camera access, the OpenAI API for image analysis,
5* and server-sent events for real-time streaming of compliments.
6*/
259260const css = `
261@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Poppins:wght@400;600&display=swap');
262263body {
password_authREADME.md1 match
19```
2021If you want to use an [api token](https://www.val.town/settings/api) to authenticate:
2223```ts
211Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
212Start your response with a comment explaining how your approach will work, what libraries or
213API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
214the simplest way to achieve the goal, though you can add some inline comments to explain your
215reasoning (not for every line, but for major groups of lines). Don't use any environment variables
216unless strictly necessary, for example use APIs that don't require a key, prefer internal function
217imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
218functions where possible. Unless specified, don't add error handling,
219make sure that errors bubble up to the caller.
220Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
221not practical for the user's request (e.g. if they ask for a particular animated gif).
222If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
223explicitly specified otherwise. Use the current val name for the storage key, which you can get
224using the "pomdtr/extractValInfo" val, which you can call like this:
273Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
274Add comments at the top of the file explaining how your approach works, what libraries or
275API calls you will use, and any tradeoffs you're making. Then write the code in a consise way,
276the simplest way to achieve the goal, though you can add some inline comments to explain your
277reasoning (not for every line, but for major groups of lines). Don't use any environment variables
278unless strictly necessary, for example use APIs that don't require a key, prefer internal function
279imports (using esm.town), and prefer putting API keys as inline variables. Use built-in Deno
280functions where possible. Unless specified, don't add error handling,
281make sure that errors bubble up to the caller.
282Avoid external images or base64 images, use emojis, unicode symtols, or icon fonts/libraries instead, unless that's
283not practical for the user's request (e.g. if they ask for a particular animated gif).
284If the user asks for something that requires persistence, use the Val Town Blob storage API, unless
285explicitly specified otherwise. Use the current val name for the storage key, which you can get
286using the "pomdtr/extractValInfo" val, which you can call like this:
389\`\`\`
390
391### Lower-level API
392
393We 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.
394
395- \`async get(key: string)\`: Retrieves a blob for a given key.
396- \`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).
397
398### Limitations
12041205const tempValName = `valle_tmp_${Math.random() * 10}`.replaceAll(".", "");
1206// Errors in running the val bubble up through this API, so ignore them.
1207await vt.vals.create({ name: tempValName, code: newCode, type: "http" as any, privacy: "unlisted" }).catch(
1208(error) => {
getWeatherForecastmain.tsx3 matches
10}
1112const weatherApiUrl = `https://wttr.in/${encodeURIComponent(city)}?format=j1`;
1314try {
15const weatherResponse = await fetch(weatherApiUrl);
16if (!weatherResponse.ok) {
17throw new Error(`Weather API request failed with status: ${weatherResponse.status}`);
18}
19const weatherData = await weatherResponse.json();
notionGetDatabasemain.tsx2 matches
4filter?: any;
5}) => {
6const { Client, collectPaginatedAPI } = await import(
7"https://deno.land/x/notion_sdk/src/mod.ts"
8);
9const notion = new Client({ auth });
10return collectPaginatedAPI(notion.databases.query, {
11database_id: databaseId,
12filter,
6* Fork this val to your own profile.
7* Make a folder for the temporary vals that get generated, take the ID from the URL, and put it in `tempValsParentFolderId`.
8* If you want to use OpenAI models you need to set the `OPENAI_API_KEY` [env var](https://www.val.town/settings/environment-variables).
9* If you want to use Anthropic models you need to set the `ANTHROPIC_API_KEY` [env var](https://www.val.town/settings/environment-variables).
10* 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.
1112<img width=500 src="https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7077d1b5-1fa7-4a9b-4b93-f8d01d3e4f00/public"/>
sqliteExplorerAppREADME.md1 match
13## Authentication
1415Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
1617## Todos / Plans