Search
val_h9bfaRPWdY
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
return 100;
return Response.json({ success: true, result });
} catch (error) {
return Response.json({
success: false,
error: error.message
}, { status: 500 });
bbaasfe
@nlnhsr
The simplest possible frontend for Breadboard as a Service
Script
The simplest possible frontend for [Breadboard as a Service](https://www.val.town/v/dglazkov/bbaas)
type NodeDescriberResult = {
title?: string;
description?: string;
inputSchema: {
properties: Record<string, Schema>;
outputSchema: {
properties: Record<string, Schema>;
type OutputValues = Record<string, unknown>;
export type BehaviorSchema =
simplifyHTML
@feb
An interactive, runnable TypeScript val by feb
HTTP
import { Readability } from "npm:@mozilla/readability@0.5.0";
export const simplifyHTML = async (request: Request) => {
const url = new URL(request.url);
const html = url.searchParams.get("html");
if (!html) {
return new Response("HTML is required in query params", { status: 400 });
const doc = new DOMParser().parseFromString(html, "text/html");
const reader = new Readability(doc);
return new Response(JSON.stringify(reader.parse()));
cuetip
@pinjasaur
cuetip Generate custom builds for my CSS-only tooltip library, cuetip . Read more . Try it out: https://pinjasaur.github.io/cuetip/customize
HTTP
# cuetip
Generate custom builds for my CSS-only tooltip library, [cuetip](https://github.com/Pinjasaur/cuetip). [Read more](https://paul.af/val-town).
Try it out: <https://pinjasaur.github.io/cuetip/customize>
// import autoprefixer from "https://esm.sh/autoprefixer";
// import postcss from "https://esm.sh/postcss";
const cors = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
const getJSON = async url => (await fetch(url)).json();
const getText = async url => (await fetch(url)).text();
sapientLavenderHerring
@maxm
WIDE Store any unstructured JSON data. Retrieve it with an expressive and efficient query system. WIDE is a library and service hosted on Val Town. Authenticate and use it with your Val Town credentials, or fork it and connect it to your own Clickhouse Instance. import { ValSession } from 'http://esm.town/v/maxm/valSession';
import { Wide } from 'http://esm.town/v/maxm/wide';
// Use your Val Town API Token to create a session
const wide = new Wide(await ValSession.new(Deno.env.get("valtown")))
// Write any data.
await wide.write([
{ user: {id: 1, name: 'Alice', email: 'alice@example.com' }},
{ user: {id: 2, name: 'Bob', email: 'bob@example.com' }},
{ user: {id: 3, name: 'Charlie', email: 'charlie@example.com' }},
]);
await wide.fields("user.")
// => [
// { fieldName: "user.email", fieldType: "string", count: 3 },
// { fieldName: "user.id", fieldType: "number", count: 3 },
// { fieldName: "user.name", fieldType: "string", count: 3 }
// ]
await wide.values("user.email")
// [
// { value: "bob@example.com", count: 1 },
// { value: "charlie@example.com", count: 1 },
// { value: "alice@example.com", count: 1 }
// ]
HTTP
# WIDE
Store any unstructured JSON data. Retrieve it with an expressive and efficient query system.
WIDE is a library and service hosted on Val Town. Authenticate and use it with your Val Town credentials, or fork it and connect it to your own Clickhouse Instance.
```ts
// Use your Val Town API Token to create a session
const wide = new Wide(await ValSession.new(Deno.env.get("valtown")))
export default async function(req: Request): Promise<Response> {
return new Response(
<!DOCTYPE html>
<html lang="en">
SignupModal
@iamseeley
@jsxImportSource https://esm.sh/hono@latest/jsx
Script
/** @jsxImportSource https://esm.sh/hono@latest/jsx */
export default function SignupModal() {
return (
<div id="signup-modal" className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 animate-fadeIn">
<div className="bg-white rounded-lg shadow-xl p-8 w-full max-w-md mx-4 mt-4 mb-0">
<div className="flex flex-col gap-1 mb-4">
<h2 className="text-xl font-bold">Create Your Profile</h2>
<p className="text-sm text-neutral-800">
Already have an account?{' '}
<a
expressHTMLExample
@stevekrouse
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
Express (deprecated)
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
export async function expressHTMLExample(
req: express.Request,
res: express.Response,
return res.send(`<h1>Hi ${req.query.name || req.body.name}!</h1>`);
javascriptCourse
@willthereader
@jsxImportSource https://esm.sh/hono@latest/jsx
HTTP
/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
// last stable version is 8
console.log("[Init] Starting Debugging_Guide val", new Date().toISOString());
export const javascriptCourse = (c: any) => {
const html = `<!DOCTYPE html>
<html lang="en">
<head>
<title>Learn JavaScript with Me</title>
<style>
body {
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>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello World</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Pacifico&display=swap');
todo_list
@tmcw
TODO List Every web project needs a todo list, right? This is val.town's first (maybe?) With a healthy dose of htmx and web fundamentals, we're packing the essentials of a TODO list with server persistence and animations into about 60 lines. The data is stored in the @tmcw.todos val, for now. Try it out.
Express (deprecated)
# [TODO List](https://tmcw-todo_list.express.val.run/)
Every web project needs a todo list, right? This is val.town's first (maybe?) With a healthy dose of [htmx](https://htmx.org/) and web fundamentals, we're packing the essentials of a TODO list with server persistence and animations into about 60 lines. The data is stored in the [@tmcw.todos](https://www.val.town/v/tmcw.todos) val, for now. Try it out.
let { todos } = await import("https://esm.town/v/tmcw/todos");
export let todo_list = (async (req, res) => {
const { default: htm } = await import("npm:htm");
const { default: vhtml } = await import("npm:vhtml");
const html = htm.bind(vhtml);
const renderTodo = (todo) => {
return html`<li data-id=${todo.id}>
<label>
testplaywright
@alexdphan
// Import Playwright using the Deno-compatible URL
Script
// Import Playwright using the Deno-compatible URL
// import { chromium } from "https://esm.sh/playwright-core";
console.info("Launching browser...");
// Use Deno.env to get the API key
const apiKey = Deno.env.get("BROWSERBASE_API_KEY");
if (!apiKey) {
console.error("BROWSERBASE_API_KEY environment variable is not set");
Deno.exit(1);
try {
const browser = await chromium.connectOverCDP(
js
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
Script
export let js = (content, options = {}) =>
new Response(content, {
headers: {
"Content-Type": "application/javascript",
...(options.headers ?? {}),
val_qM2o6HW9ZX
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_qM2o6HW9ZX(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const checkRandomness = (numSamples) => { const results = { even: 0, odd: 0 }; for (let i = 0; i < numSamples; i++) { const randomNum = Math.floor(Math.random() * 100); if (randomNum % 2 === 0) { results.even++; } else { results.odd++; } } return results; }; return checkRandomness(1000);
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
val_GU93iYgQpG
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_GU93iYgQpG(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Create a fun ASCII art of a pixel dog
const dogAscii = `
return dogAscii;
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,