Search

Results include substring matches and semantically similar vals. Learn more
rodrigotello avatar
vtInspoHTML
@rodrigotello
An interactive, runnable TypeScript val by rodrigotello
Script
export function vtInspoHTML(req, res) {
res.send(
valTownInspoList.map((valTownInspo) =>
`<h3>Daily Val Town inspiration</h3>
<h1>${valTownInspo.title}</h1>
<p>${valTownInspo.description}</p>
<a href="https://val.town/${valTownInspo.val}"><img src="https://val.town/v/${valTownInspo.val}.png" style="max-width:576px
<p>
</p>`
).join("\n"),
rld avatar
runGET
@rld
// Forked from @stevekrouse.runGET
Script
import { id } from "https://esm.town/v/rld/id";
export let runGET = id(
"This is a GET request to the @rld.runGET endpoint in val.town",
// Forked from @stevekrouse.runGET
alp avatar
proxyFetch10
@alp
An interactive, runnable TypeScript val by alp
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const proxyFetch10 = async (req, res) => {
const { url, options } = req.body;
try {
const response = await fetch(url, options);
return res.status(response.status).send(await response.text());
} catch (e) {
const errorMessage = e instanceof Error ? e.message : "Unknown error";
console.error("Failed to initiate fetch", e);
return res.status(500).send(`Failed to initiate fetch: ${errorMessage}`);
kylebutts avatar
postWebhook1
@kylebutts
An interactive, runnable TypeScript val by kylebutts
Script
export let postWebhook1 = async (req, res) => {
const a = await newRSSItems({
url: "https://elliot.website/editor/feed.rss",
lastRunAt: new Date("Mon, 31 Oct 2021 00:00:00 +0000"),
res.send(`
<h1>My latest RSS</h1>
<ul>${a
.map(
({ title, link, description, pubDate }) => `
<li>
stevekrouse avatar
plants
@stevekrouse
Made with val writer With prompt The app is just a simple plant watering app. Had a bunch of plants with different watering schedules. I want to be able to add new plants. I want to open the app and mark a plant as watered. I want to track all watering events. Store only a `waterings` table where the plant name is a string.
HTTP (deprecated)
Made with [val writer](https://stevekrouse-valwriter.web.val.run/?description=The+app+is+just+a+simple+plant+watering+app.+Ha
With prompt
The app is just a simple plant watering app.
Had a bunch of plants with different watering schedules.
I want to be able to add new plants.
I want to open the app and mark a plant as watered.
/** @jsxImportSource npm:hono@3/jsx */
// Initialize the SQLite database and create the waterings table
sqlite.execute(`
CREATE TABLE IF NOT EXISTS waterings (
todepond avatar
htmlExample
@todepond
HTML example This is an example of how to return an HTML response. You can also preview it at https://andreterron-htmlExample.web.val.run?name=Andre
HTTP (deprecated)
# HTML example
This is an example of how to return an HTML response.
You can also preview it at https://andreterron-htmlExample.web.val.run?name=Andre
// View at https://andreterron-htmlExample.web.val.run?name=Andre
export default async function(req: Request): Promise<Response> {
const query = new URL(req.url).searchParams;
// Read name from the querystring or body. Defaults to "you" if not present.
const name = query.get("name") || (await req.json().catch(() => ({}))).name || "you";
// Returns the HTML response
return new Response(`<h1>Hi ${name}!</h1>`, {
alp avatar
proxyFetch8
@alp
An interactive, runnable TypeScript val by alp
Script
import { fetch } from "https://esm.town/v/std/fetch";
export const proxyFetch8 = async (req, res) => {
const { url, options } = req.body;
try {
const response = await fetch(url, options);
return res.status(response.status).send(await response.text());
} catch (e) {
const errorMessage = e instanceof Error ? e.message : "Unknown error";
console.error("Failed to initiate fetch", e);
return res.status(500).send(`Failed to initiate fetch: ${errorMessage}`);
antonnyman avatar
honoExample
@antonnyman
Hono Here's an example using the Hono server library with the Web API . It works great! Server examples Hono Peko Itty Router Nhttp
HTTP (deprecated)
# Hono
Here's an example using the [Hono](https://hono.dev/) server library with the [Web API](https://docs.val.town/api/web). It wo
### Server examples
- [Hono](https://www.val.town/v/tmcw.honoExample)
- [Peko](https://www.val.town/v/tmcw.pekoExample)
- [Itty Router](https://www.val.town/v/tmcw.ittyRouterExample)
export const honoExample = async (req: Request) => {
const { Hono } = await import("npm:hono@3");
const app = new Hono();
app.get("/", (c) => c.text("Hono?"));
stevekrouse avatar
valOutput
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export async function valOutput(req: Request) {
const url = new URL(req.url);
const pattern = /^\/([^\/]+)\/([^@]+)(?:@([^\.]+))?$/;
const match = url.pathname.match(pattern);
if (!match) {
return new Response("invalid request", { status: 400 });
const author = match[1];
const name = match[2];
const val = await fetchJSON(
`https://api.val.town/v1/alias/${author}/${name}`,
sherry007 avatar
parserSampleJSON
@sherry007
An interactive, runnable TypeScript val by sherry007
Script
export const parserSampleJSON = (async () => {
const { PromptTemplate } = await import("npm:langchain/prompts");
const { StructuredOutputParser } = await import(
"npm:langchain/output_parsers"
// With a `StructuredOutputParser` we can define a schema for the output.
const parser = StructuredOutputParser.fromNamesAndDescriptions({
answer: "answer to the user's question",
source: "source used to answer the user's question, should be a website.",
const formatInstructions = parser.getFormatInstructions();
const prompt = new PromptTemplate({
tmcw avatar
elysiaExample
@tmcw
Elysia example This is how you can use Elysia with Val Town.
HTTP (deprecated)
# Elysia example
This is how you can use [Elysia](https://elysiajs.com) with Val Town.
export const elysiaExample = async (req) => {
const { Elysia } = await import("https://esm.sh/elysia@0.7.15");
const app = new Elysia()
.get("/", () => "Hello Elysia");
return app.fetch(req);
curtcox avatar
_not_actually_private_so_that_you_can_see_it
@curtcox
This is public so you can see what's in it. If it had real secrets, it should be private. See https://www.val.town/v/curtcox/reply_to_slack_message
HTTP (deprecated)
This is public so you can see what's in it. If it had real secrets, it should be private.
See https://www.val.town/v/curtcox/reply_to_slack_message
import { reply_to_slack_message, SlackConfig } from "https://esm.town/v/curtcox/reply_to_slack_message";
// This is for informational purposes only.
// It needs real tokens to work.
export const chatio = (req: Request) => {
const config: SlackConfig = {
slackToken: "See Val Town docs for how to get this token",
slackVerificationToken: "See Val Town docs for how to get this token",
return reply_to_slack_message(req, processor, config);
byjonathanleung avatar
setZ
@byjonathanleung
An interactive, runnable TypeScript val by byjonathanleung
Script
let { Z } = await import("https://esm.town/v/byjonathanleung/Z");
export const setZ = (newValue) => {
Z = newValue;
return Z
andreterron2 avatar
_
@andreterron2
An interactive, runnable TypeScript val by andreterron2
Script
export const _ = import("npm:lodash");
whatrocks avatar
foo
@whatrocks
// email yourself as easily as logging to the console
Script
// email yourself as easily as logging to the console
export async function foo() {
const username = "whatrocks";
const today = new Date().toDateString();
console.log("today: ", today);
const url = `https://searchcaster.xyz/api/search?text=%E2%8C%86&username=${username}`;
let old_fling = "";
const response = await fetch(url);
const jsonData = await response.json();
console.log(jsonData);