Search

orangeMite
@pomdtr
https://pomdtr-orangemite.web.val.run
HTTP
https://pomdtr-orangemite.web.val.run
export default function(req) {
return new Response(req.referrer, {
status: 200,
zARCHIVE_html_Pages
@arfan
// Shared HTML components
HTTP
const MESSAGE_STORAGE_KEY = new URL(import.meta.url).pathname.split("/").at(-1) + "_user_messages";
// Shared HTML components
function getPageHeader(pageTitle: string) {
return `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${pageTitle} - Val Town Example</title>
keenScarletWoodpecker
@roadlabs
tldraw computer custom endpoint example This val is an example custom endpoint for tldraw computer 's data component. Usage To use this val with tldraw.computer, follow these steps: Fork this Val. Click the Copy endpoint button on your new Val. Open a project on tldraw.computer Create a Data component in your tldraw computer project In the Source dropdown, select Custom and the POST method Paste the endpoint into Data component's the HTTP Endpoint input. Run the component. To see the output, connect the Data component to a Text component. How it works In tldraw computer, you can configure a Data component to use a custom HTTP endpoint as its data source. You can also configure the request method, either GET or POST. If a Data component's request method is POST, then when the component next updates, it will send a POST request to the endpoint. The request's body will contain an array of the Data objects that the component had received as inputs. If the request method if GET, then the component will only make the request—its body will be empty. In both cases, the component will expect back a response that includes an array of Data objects these objects will be passed along as the data component's outputs. The endpoint (your forked version of this Val) can do whatever it likes between the request and response, but the response must include data in the correct format. If the format is wrong, the computer app will create a text data object instead that includes the response as plain text. Support If you're running into any difficulties, check out the #tldraw-computer channel on the tldraw discord.
HTTP
# tldraw computer custom endpoint example
This val is an example custom endpoint for [tldraw computer](tldraw.computer)'s data component.
### Usage
To use this val with tldraw.computer, follow these steps:
1. Fork this Val.
2. Click the **Copy endpoint** button on your new Val.
type BooleanData = {
type: "boolean";
text: "true" | "false" | "maybe";
name?: string | undefined;

emailMeWhenBadAirQuality
@logan
An interactive, runnable TypeScript val by logan
Script
export async function emailMeWhenBadAirQuality({ lat, long }: {
lat: number;
long: number;
// Get date and API key
const now = new Date();
const apiKey = process.env.WEATHER_BIT_API_KEY;
if (!apiKey) {
throw new Error("Must define WEATHER_BIT_API_KEY in secrets");
const res = await fetch(
`https://api.weatherbit.io/v2.0/current/airquality?lat=${lat}&lon=${long}&key=${apiKey}`,
ZineFairs
@sylvea
// Scrapes the stencil fairs website and gets the upcoming events
Cron
const WEBSITE_URL = "https://www.stencil.wiki/fairs";
interface Event {
name?: string;
dates?: string;
location?: string;
// Scrapes the stencil fairs website and gets the upcoming events
async function scrapeWebsiteAndGetEvents(url: string): Promise<Array<Event>> {
const response = await fetch(url);
if (!response.ok) {
throw new Error(`Failed to fetch ${url}: ${response.status} ${response.statusText}`);
urbaneAquamarineDolphin
@toowired
An interactive, runnable TypeScript val by toowired
Script
export const windsurfIDE = {
async executeCommand(command) {
switch(command.type) {
case 'start-goal':
return await this.handleStartGoal(command.goal);
case 'complete-task':
return await this.handleCompleteTask(command.taskId);
case 'auto-next':
return await this.handleAutoNext();
case 'load-memory':
grimPinkLimpet
@jdan
// This approach will use the Notion API to update a block's color.
HTTP
// This approach will use the Notion API to update a block's color.
// We'll create a simple HTML page with a button, and use JavaScript to handle
// the click event and make a request to our Val Town function.
// The function will then make a request to the Notion API to update the block.
const app = new Hono();
// Main page with the button
app.get("/", (c) => {
return c.html(`
<!DOCTYPE html>
<html lang="en">

multipleKeysAndMemoryConversationChainExample
@jacoblee93
An interactive, runnable TypeScript val by jacoblee93
Script
export const multipleKeysAndMemoryConversationChainExample = (async () => {
const { ChatOpenAI } = await import(
"https://esm.sh/langchain/chat_models/openai"
const { BufferMemory } = await import("https://esm.sh/langchain/memory");
const {
ChatPromptTemplate,
SystemMessagePromptTemplate,
HumanMessagePromptTemplate,
MessagesPlaceholder,
} = await import("https://esm.sh/langchain/prompts");
htmlExample
@willthereader
Returning HTML from the Val Town Web API This just lets you use the standard Response object with our Web API to return an HTML response from this Val.
HTTP
# Returning HTML from the Val Town Web API
This just lets you use the standard [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) object with our [Web API](https://docs.val.town/api/web) to return an HTML response from this Val.
export const htmlExample = () =>
new Response("<h1>Hello, world</h1>", {
headers: {
"Content-Type": "text/html",
friendship2
@mbo
https://maxbo.me/friendship2.html
HTTP
# https://maxbo.me/friendship2.html
// This approach uses Val Town's Blob storage for persistence of friendship bracelets.
// We'll store an array of bracelet objects, each containing a unique ID and the provided information.
// The main function handles both GET and POST requests, allowing for creating new bracelets and retrieving them.
// When no ID is provided in the GET request, it will list all bracelets.
const KEY = new URL(import.meta.url).pathname;
interface Bracelet {
id: string;
content: string;
creator: string;
honoJSXExample
@maxm
@jsxImportSource npm:hono@3/jsx
HTTP
/** @jsxImportSource npm:hono@3/jsx */
export const honoExample = () => {
const jsx = <div>Test {1 + 1}</div>;
return new Response(jsx.toString(), {
headers: {
"Content-Type": "text/html",
FindFraudTrendsUsingGPT
@mjweaver01
FraudTrendsGPT Generate real-time Fraud Trend Reports using GPT-4o Goal This agent is designed to find trends in merchant transaction reports, and produce a real time report. Reports are complete with relevant data tables and Mermaid charts. Semi-Data-Agnostic This agent is semi-agnostic to the data provided. Meaning, it will provide a report so long as the provided data is shaped similarly, or the prompt is updated to support the new data shape. Agent Reusability Moreover, this agent can be rewritten for any number of use cases. With some variable renaming, and rewriting of the prompt, this should produce very accurate data analytic reports for any data provided.
HTTP
# FraudTrendsGPT
> Generate real-time Fraud Trend Reports using GPT-4o
## Goal
This agent is designed to find trends in merchant transaction reports, and produce a real time report.
Reports are complete with relevant data tables and Mermaid charts.
## Semi-Data-Agnostic
const trendGPT = async (data, onData) => {
const openai = new OpenAI();
const chatStream = await openai.chat.completions.create({
messages: [
newChatGPT35
@bingo16
An interactive, runnable TypeScript val by bingo16
Script
export let newChatGPT35 = async ({ req, res }) => {
const postData = {
model: "gpt-3.5-turbo",
messages: [
{ role: "system", content: "You are a powerful chatGPT assistant." },
role: "user",
content: "请介绍一下你自己",
const getCompletion = async () => {
const response = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",

getTodaysInfo
@briscoe
An interactive, runnable TypeScript val by briscoe
Script
export const getTodaysInfo = (async (req: Interval, res: express.Response) => {
const tides = await getTideTimes();
const pool = await getPoolTimes();
const tidesString = `<strong>High tides</strong>: ${
tides.filter((t) => t.tide === "High Tide").map((t) =>
`${t.time} (${t.height})`
).join(" & ")
let poolString = "<strong>Pool times today</strong>";
if (pool.today.length > 0)
poolString += `<ul> ${
valCoinApi
@aggy
I have no idea how crypto really works, this is just a guess
HTTP
I have no idea how crypto really works, this is just a guess
const app = new Hono();
app.use("/*", cors());
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
const { v4: uuidv4 } = await import("https://esm.sh/uuid");
const SCHEMA_VERSION = 1;
const KEY = new URL(import.meta.url).pathname.split("/").at(-1);
await sqlite.execute(`
CREATE TABLE IF NOT EXISTS ${KEY}_valcoin_${SCHEMA_VERSION} (
hash TEXT PRIMARY KEY,