Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
exampleExpressHandler
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export async function exampleExpressHandler(
req: express.Request,
res: express.Response
return res.send(req.query.name);
rayman avatar
QuillEditor
@rayman
Quill.js WYSIWYG Basic WYSIWYG rich text editor, using quill.js . Press the "Get HTML" button to show the HTML in an alert window.
HTTP
# Quill.js WYSIWYG
Basic WYSIWYG rich text editor, using [quill.js](https://quilljs.com/).
Press the "Get HTML" button to show the HTML in an alert window.
export default async function(req: Request) {
if (req.method === "POST") {
const name = (await req.formData()).get("name");
return new Response("Hello World");
return new Response(
`<html>
<head>
shaya avatar
keriatShemaReminser
@shaya
An interactive, runnable TypeScript val by shaya
Script
export async function keriatShemaReminser() {
const today = new Date().toISOString().split("T")[0];
const city = "IL-Jerusalem";
const { times } = await (
await fetch(
`https://www.hebcal.com/zmanim?cfg=json&city=${city}&date=${today}`
).json();
const sofZmanKeriatShema = times.sofZmanShma;
const timeInDay = new Date(sofZmanKeriatShema).toLocaleTimeString("en", {
timeStyle: "short",
stevekrouse avatar
passkey_script
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
(async () => {
if (
SimpleWebAuthnBrowser.browserSupportsWebAuthn()
&& (await SimpleWebAuthnBrowser.platformAuthenticatorIsAvailable())
&& (await SimpleWebAuthnBrowser.browserSupportsWebAuthnAutofill())
log("Passkeys are supported! ✅");
document.getElementById("passkeys_check").innerText = "Passkeys are supported! ✅";
document.getElementById("auth").disabled = false;
} else {
log("Passkeys are not supported! ❌");
mario avatar
chat
@mario
// https://api.val.town/express/@nimalu.chat
Script
// https://api.val.town/express/@nimalu.chat
export const chat = (req, res) => {
const messages = chatMessages
.map(
({ message, sender }) =>
`<li><span class="font-semibold text-gray-900">${sender}: </span>${message}</li>`
.reverse()
.join("");
res.set("Content-Type", "text/html");
res.send(`
janpaul123 avatar
valle_tmp_941646362281053813810573876504528
@janpaul123
This code sets up a styled comment box system using Tailwind CSS. * It leverages Deno's blob storage for persistence, * and renders an HTML form to accept new comments, * while displaying all existing comments.
HTTP
/** This code sets up a styled comment box system using Tailwind CSS.
* It leverages Deno's blob storage for persistence,
* and renders an HTML form to accept new comments,
* while displaying all existing comments.
// Key for blob storage
const COMMENTS_KEY = "comments_storage";
// HTML template for the form and comments list
const getHtml = (comments: string[]) => `
<html>
<head>
demo avatar
naclValidateRequest
@demo
An interactive, runnable TypeScript val by demo
Script
export let naclValidateRequest = async (req: express.Request, publicKey) => {
const { default: nacl } = await import("npm:tweetnacl@1.0.3");
const signature = req.get("X-Signature-Ed25519");
const timestamp = req.get("X-Signature-Timestamp");
const body = JSON.stringify(req.body); // rawBody is expected to be a string, not raw bytes
const isVerified = nacl.sign.detached.verify(
Buffer.from(timestamp + body),
Buffer.from(signature, "hex"),
Buffer.from(publicKey, "hex"),
return isVerified;
sourishkrout avatar
runmeTotals
@sourishkrout
An interactive, runnable TypeScript val by sourishkrout
HTTP
import { runmeTotalsState } from "https://esm.town/v/sourishkrout/runmeTotalsState";
export function handler(request: Request) {
const data = runmeTotalsState;
return Response.json({ data });
canglangdahai avatar
beigeEarthworm
@canglangdahai
An interactive, runnable TypeScript val by canglangdahai
HTTP
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
status: 204,
const openai = new OpenAI();
try {
var body = await req.json();
dhvanil avatar
val_E1oovKNSVp
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
export default async function handler(req) {
try {
const result = await (async () => {
function fibonacci() { let a = 0, b = 1; while (b < 1000) { let temp = b; b = a + b; a = temp; } return b;
fibonacci();
return Response.json({ success: true, result });
} catch (error) {
return Response.json({
success: false,
error: error.message
saolsen avatar
connect4_agent
@saolsen
An interactive, runnable TypeScript val by saolsen
Script
export type Agent = (state: connect4.State) => connect4.Action;
export type AsyncAgent = (state: connect4.State) => Promise<connect4.Action>;
export function connect4_agent(agent: Agent | AsyncAgent) {
const app = new Hono();
app.get("/", (c) => c.json("connect4 agent"));
app.post("/", async (c) => {
const body = await c.req.json();
const parsed = connect4.State.safeParse(body);
if (!parsed.success) {
return c.json({ error: parsed.error }, 400);
dhvanil avatar
val_Ana3w2z9u6
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_Ana3w2z9u6(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const checkAnomalies = () => {
const expectedRange = [0, 100];
const randomValue = Math.random() * 100;
return randomValue < expectedRange[0] || randomValue > expectedRange[1] ? 'Anomaly detected!' : 'No anomalies.';
checkAnomalies();
// Return the result in a properly formatted response
dhvanil avatar
web_whzyD0pbS0
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_whzyD0pbS0(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 Dark Hours: When AI Goes Quantum</title>
<style>
body {
font-family: 'Courier New', monospace;
janpaul123 avatar
valle_tmp_221510857149863205700813425291562
@janpaul123
// This val responds with an HTML form styled with CSS to input the user's name and greets them upon form submission
HTTP
// This val responds with an HTML form styled with CSS to input the user's name and greets them upon form submission
export default async function(req: Request): Promise<Response> {
if (req.method === "POST") {
const formData = new URLSearchParams(await req.text());
const name = formData.get("name") || "stranger";
const htmlResponse = `
<style>
body { font-family: Arial, sans-serif; text-align: center; }
h1 { color: #333; }
form { margin-top: 20px; }
fgeierst avatar
AriaSnapshotFromUrl
@fgeierst
compare https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/injected/ariaSnapshot.ts
HTTP
compare https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/injected/ariaSnapshot.ts
export default async function server(request: Request): Promise<Response> {
// Parse the URL from the request query parameters
const url = new URL(request.url).searchParams.get('url');
let html: string;
if (url) {
// Fetch the webpage
const response = await fetch(url, {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124