Search
CS1200_jokeGenerator
@moouhss
An interactive, runnable TypeScript val by moouhss
Cron
import { email } from "https://esm.town/v/std/email?v=11";
export async function emailRandomJoke() {
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
val_t5b9tBdMU6
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
glifbux
@jamiedubs
this is the fake, zero-security economy for glif chatbots https://glif.app it is the poorest man's blockchain see also our imaginary NFT marketplace: https://www.val.town/v/jamiedubs/glifinventory
HTTP
function normalizeAddress(address: string): string {
async function initializeDatabase() {
async function getBalance(address: string): Promise<number> {
async function setBalance(address: string, amount: number) {
async function incrementBalance(address: string, amount: number) {
async function decrementBalance(address: string, amount: number) {
async function getAllAccounts(): Promise<{ address: string; balance: number }[]> {
async function mint(address: string, amount: number) {
function generateInstructions(baseUrl: string): string {
function handleHome(baseUrl: string): ApiResponse {

codeOnValTown_test
@vladimyr
// export default modifyFetchHandler(serveHtml, { val: { handle: author, name } });
HTTP
import { modifyFetchHandler } from "https://esm.town/v/vladimyr/codeOnValTown";
const { author, name } = extractValInfo(import.meta.url);
async function serveHtml(req: Request): Promise<Response> {
return new Response(
<html>
redditSearch
@sarahxc
Use Browserbase and Puppeteer to monitor and scrape reddit search results.
HTTP
// Use Browserbase (with proxy) to search and scrape Reddit results
export async function redditSearch({
query,
await browser.close();
function constructSearchUrl(query: string): string {
const encodedQuery = encodeURIComponent(query).replace(/%20/g, "+");
return `https://www.reddit.com/search/?q=${encodedQuery}&type=link&t=week`;
async function extractPostData(page: any): Promise<Partial<ThreadResult>[]> {
return page.evaluate(() => {
date_published: timeElement?.textContent?.trim() || "",
async function processPostData(postData: Partial<ThreadResult>[]): Promise<ThreadResult[]> {
const processedData: ThreadResult[] = [];

flutteringVioletBird
@stevekrouse
CronGPT This is a minisite to help you create cron expressions, particularly for crons on Val Town. It was inspired by Cron Prompt , but also does the timezone conversion from wherever you are to UTC (typically the server timezone). Tech Hono for routing ( GET / and POST /compile .) Hono JSX HTMX (probably overcomplicates things; should remove) @stevekrouse/openai, which is a light wrapper around @std/openai I'm finding HTMX a bit overpowered for this, so I have two experimental forks without it: Vanilla client-side JavaScript: @stevekrouse/cron_client_side_script_fork Client-side ReactJS (no SSR): @stevekrouse/cron_client_react_fork I think (2) Client-side React without any SSR is the simplest architecture. Maybe will move to that.
HTTP
* HTMX (probably overcomplicates things; should remove)
* @stevekrouse/openai, which is a light wrapper around @std/openai
I'm finding HTMX a bit overpowered for this, so I have two experimental forks without it:
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [description, setDescription] = useState("Thu, Sep 26, 2024 2:25 PM EDT");
try {
const response = await fetch("https://esm.town/v/stevekrouse/openai", {
method: "POST",
</div>
function DateComponent({ dateString }) {
if (!dateString) {
<a href={href} className="text-blue-500 hover:text-blue-700" target="_blank" rel="noopener noreferrer">{children}</a>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
export default async function server(request: Request): Promise<Response> {
return new Response(`
valle_tmp_7989374227722403845259498123896
@janpaul123
// This val will respond with an HTML page saying "Hello, world!" with fun CSS styles.
HTTP
// This val will respond with an HTML page saying "Hello, world!" with fun CSS styles.
export default async function main(): Promise<Response> {
const htmlContent = `
<!DOCTYPE html>

myApi
@juanan
An interactive, runnable TypeScript val by juanan
Script
export function myApi(name) {
return "hi " + name;
medicineLabelAnalyzerApp
@imnk
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function App() {
const [image, setImage] = useState<File | null>(null);
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
if (request.method === 'POST' && new URL(request.url).pathname === '/analyze') {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
try {
String.fromCharCode(...new Uint8Array(imageBytes))
const completion = await openai.chat.completions.create({
model: "gpt-4o-mini",

myApi
@klepra
An interactive, runnable TypeScript val by klepra
Script
export function myApi(name) {
return "hi " + name;
greenWren
@deepfates
@jsxImportSource https://esm.sh/preact
HTTP
/** @jsxImportSource https://esm.sh/preact */
import { render } from "npm:preact-render-to-string";
export default async function(req: Request) {
if (req.method === "POST") {
const name = (await req.formData()).get("name");

TodayForAnnalisa
@mttlws
An interactive, runnable TypeScript val by mttlws
Express (deprecated)
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export async function TodayForAnnalisa(req: express.Request, res: express.Response) {
const { activity } = await fetchJSON(
"https://www.boredapi.com/api/activity",
web_La1PCylq8q
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_La1PCylq8q(req) {
return new Response(`<!DOCTYPE html>
<html>