Search
saveEmailSignupsDeerSpringBakery
@jcoleman
An interactive, runnable TypeScript val by jcoleman
HTTP
export const renderFormAndSaveData = async (req: Request) => {
// Get existing list of submitted email addresses
let submittedEmailAddresses = await blob.getJSON("bakerSubmittedEmailAddresses") as string[];
// If there were no email addresses stored, create an empty array
submittedEmailAddresses ??= [];
const origin = req.headers.get("origin");
console.log(origin);
// Pick out the form data
const formData = await req.formData();
const emailAddress = formData.get("email") as string;
duckdbExample
@nbbaier
An interactive, runnable TypeScript val by nbbaier
Script
export let duckdbExample = (async () => {
async function createWorker(url: string) {
const workerScript = await fetch(url);
const workerURL = URL.createObjectURL(await workerScript.blob());
return new Worker(workerURL, { type: "module" });
const duckdb = await import(
"https://cdn.jsdelivr.net/npm/@duckdb/duckdb-wasm@1.17.0/+esm"
const bundles = duckdb.getJsDelivrBundles();
const bundle = await duckdb.selectBundle(bundles);
const logger = new duckdb.ConsoleLogger();
icsTestServe
@tal
An interactive, runnable TypeScript val by tal
Script
export const icsTestServe = async () => {
const ical = await import("npm:ical-generator");
const calendar = ical.default({ name: "Tal's testing calendar" });
calendar.method(ical.ICalCalendarMethod.PUBLISH);
const startTime = new Date();
calendar.createEvent({
start: startTime,
allDay: true,
summary: "Example Event",
description: "It works ;)",
valle_tmp_174032832928853859223153633480038
@janpaul123
// This script will respond with a basic HTML page, including styled content and an animated cat GIF that crawls around the screen.
HTTP
// This script will respond with a basic HTML page, including styled content and an animated cat GIF that crawls around the screen.
* HTTP Val: Hello World Example (HTML Response with CSS and Animated Cat GIF)
* This script will respond with a basic HTML page that says "Hello world" to any incoming HTTP request, and includes some cool CSS styles and an animated cat GIF.
export default async function(req: Request): Promise<Response> {
const catGifURL = "https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif";
const htmlContent = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
exampleHTTP
@maxm
An interactive, runnable TypeScript val by maxm
HTTP
export function handler(request: Request) {
return Response.json({ ok: true });
web_9rLrcqLIFi
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_9rLrcqLIFi(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Cheese Volcano Pizza Masterpiece</title>
<style>
body {
font-family: 'Arial', sans-serif;
chat
@kirineko
An interactive, runnable TypeScript val by kirineko
Script
export const chat = async (
prompt: string | object = "Hello world",
options = {},
// Initialize OpenAI API stub
const { Configuration, OpenAIApi } = await import(
"https://esm.sh/openai@3.3.0"
console.log(process.env);
// const configuration = new Configuration({
// apiKey: process.env.OPENAI,
// const openai = new OpenAIApi(configuration);
qrCodeWebhook
@d17e
Get the SVG for a plottable QR code: curl https://d17e-qrcodewebhook.web.val.run -H "Content-Type: application/json" -d '{ "value":"https://qr.d17e.dev", "ecl": "L", "penMmSize": 0.5}'
HTTP
Get the SVG for a plottable QR code:
```bash
curl https://d17e-qrcodewebhook.web.val.run -H "Content-Type: application/json" -d '{ "value":"https://qr.d17e.dev", "ecl": "L", "penMmSize": 0.5}'
interface QRConfig {
value: string;
ecl: string;
penMmSize: number;
function generateQrSVGPaths(
qrData: boolean[][],
penWidth: number,
valle_tmp_069034869725444597641897580363524
@janpaul123
// Define the key for blob storage
HTTP
// Define the key for blob storage
const STORIES_KEY = "hn_stories";
const INITIAL_STORIES = 30;
// Generate some sample stories to start with
async function initStories() {
const stories = [];
for (let i = 1; i <= INITIAL_STORIES; i++) {
stories.push({
id: i,
title: `Sample Story ${i}`,
addScript
@liamdanielduffy
// load 'src' from CDN if it isn't already
Script
// load 'src' from CDN if it isn't already
// callback is a string that defines a function you'd like to run after your script loads
export function addScript(src: string, callback?: Function): string {
return `
<script type="text/javascript">
// check if the script tag already exists
const script = const scriptTag = document.querySelector(script[src="${src}]);;
// if the script tag does not exist, add it to the document
if (!script) {
var script = document.createElement('script');
valle_tmp_59257570592856375817499399720445
@janpaul123
// This val serves a HTML page that contains a Wordle game with custom CSS for a fun, colorful style
HTTP
// This val serves a HTML page that contains a Wordle game with custom CSS for a fun, colorful style
// Import dependencies
const app = new Hono();
app.get("/", async (c) => {
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
homePage
@theverything
An interactive, runnable TypeScript val by theverything
Script
import { fetch } from "https://esm.town/v/std/fetch";
export let homePage = async (req: express.Request, res: express.Response) => {
const p = await fetch("https://www.jeffreyhorn.com");
const html = await p.text();
res.type("html");
res.send(html);
alias
@neverstew
An interactive, runnable TypeScript val by neverstew
Script
export function alias<P extends Params>(params: P): Promise<Result<P>> {
const username = params.username;
let url = `https://api.val.town/v1/alias/${username}`;
if ("valName" in params)
url = url + `/${params.valName}`;
const headers: HeadersInit = {};
if ("valName" in params && params.token)
headers.Authorization = `Bearer ${params.token}`;
return fetchJSON(url, { headers });
type UserParams = {
srcbackend
@temptemp
// console.log(await streamwishExtractor("ru04dsfz6sjj"));
Script
const nanoid = customAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", 10);
export interface DataSheet {
site: "dood" | "streamtape" | "streamwish" | null;
siteSpecificId: string;
extractedURL: string;
accessHeaders: {};
fromCache: boolean;
subtitles?: {
language: string;
url: string;
tom_og
@tomcritchlow
A simplified version of this: https://www.val.town/v/panphora/canvasText to generate open graph images dynamically for my blog
HTTP
A simplified version of this: https://www.val.town/v/panphora/canvasText to generate open graph images dynamically for my blog
export let canvasText = async (req: Request) => {
const query = new URL(req.url).searchParams;
const { loadImage, createCanvas } = await import(
"https://deno.land/x/canvas/mod.ts"
const canvas = createCanvas(1200, 675);
const ctx = canvas.getContext("2d");
let canvasWidth = canvas.width;
let canvasHeight = canvas.height;
ctx.clearRect(0, 0, canvasWidth, canvasHeight);