Search
dns
@stevekrouse
@jsxImportSource npm:hono@3/jsx
HTTP
/** @jsxImportSource npm:hono@3/jsx */
const app = new Hono();
export default valTownBadgeMiddleware(app.fetch, import.meta.url);
app.get("/", (c) => {
return c.html(
<html>
<head>
<title>DNS Lookup Tool</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="icon" href="https://fav.farm/🔎" />
val_vgmrhMlQrz
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_vgmrhMlQrz(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const calculateFractalDimension = (points) => { const boxCount = (size) => { let count = 0; for (let i = 0; i < points.length; i++) { if (points[i].x < size && points[i].y < size) count++; } return count; }; const sizes = []; for (let size = 1; size <= 100; size *= 2) { sizes.push(size); } const counts = sizes.map(size => boxCount(size)); const logCounts = counts.map(count => Math.log(count)); const logSizes = sizes.map(size => Math.log(size)); const slope = (logCounts[1] - logCounts[0]) / (logSizes[1] - logSizes[0]); return -slope; }; const mandelbrotPoints = []; const sierpinskiPoints = []; // Generate points for Mandelbrot and Sierpinski triangle for (let x = -2; x <= 2; x += 0.01) { for (let y = -2; y <= 2; y += 0.01) { // Mandelbrot set calculation const c = { x, y }; let z = { x: 0, y: 0 }; let iterations = 0; while (z.x * z.x + z.y * z.y <= 4 && iterations < 100) { const temp = z.x * z.x - z.y * z.y + c.x; z.y = 2 * z.x * z.y + c.y; z.x = temp; iterations++; } if (iterations === 100) mandelbrotPoints.push({ x, y }); } } for (let i = 0; i < 5; i++) { const size = Math.pow(2, i); sierpinskiPoints.push({ x: 0, y: 0 }); // Add points for Sierpinski triangle } return { mandelbrotDimension: calculateFractalDimension(mandelbrotPoints), sierpinskiDimension: calculateFractalDimension(sierpinskiPoints) };
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
val_l8coqheYHp
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_l8coqheYHp(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Create a pixel art cat inspired by the pixel art shown
const pixelKitty = `
▐ w ▌
return pixelKitty;
// Return the result in a properly formatted response
return new Response(JSON.stringify({
val_BoN8lgrbOT
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
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 });
renderObject
@joey
An interactive, runnable TypeScript val by joey
Script
export const renderObject = (
req: express.Request,
res: express.Response,
object = {}
// return some html
const json = JSON.stringify(object, null, 2);
res.send(`
<html>
<body>
<h1>val.town</h1>
web_J4lwD9OeFC
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_J4lwD9OeFC(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Retro Space Interface</title>
<style>
body {
margin: 0;
renderFormAndSaveData
@vtdocs
An interactive, runnable TypeScript val by vtdocs
Express (deprecated)
let { submittedEmailAddresses } = await import("https://esm.town/v/vtdocs/submittedEmailAddresses");
export const renderFormAndSaveData = async (
req: express.Request,
res: express.Response,
// A visit from a web browser? Serve a HTML page with a form
if (req.method === "GET") {
return res.send(`
<!DOCTYPE html>
<html>
<head>
val_ev8r7AvmOt
@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 });
signInWithValTownDemo
@easrng
@easrng/signInWithValTown Demo An example of how to add authentication backed by val.town accounts to a val.
HTTP
# @easrng/signInWithValTown Demo
An example of how to add authentication backed by val.town accounts to a val.
[![Open](https://easrng-button.express.val.run/Open)](https://easrng-signInWithValTownDemo.web.val.run)
/** @jsx jsx */
/** @jsxFrag Fragment */
createContext,
type FC,
Fragment,
jsx,
type PropsWithChildren,
htmlHandler
@jessmartin
An interactive, runnable TypeScript val by jessmartin
Express (deprecated)
export let htmlHandler = (req, res) => {
res.send("<html><head></head><body><h1>Hello world</h1></body></html>");
val_OPFDaimIjZ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_OPFDaimIjZ(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const subtract = (a, b) => a - b; return subtract(10, 4);
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
web_iTwjIXAEMt
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_iTwjIXAEMt(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Lil Website</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; background-color: #f4f4f4; }
h1 { color: #333; }
MaplBuild
@aquapi
An interactive, runnable TypeScript val by aquapi
HTTP
console.time("Startup 500 routes");
const app = router();
for (let i = 0; i < 500; i++)
app.get(`/${i}/*/${i}`, {
type: "text",
fn: Math.random() < 0.5 ? () => "Hi" : async (c) => c.req.text(),
const fetch = jitc(app);
console.timeEnd("Startup 500 routes");
console.log("Fetch function", fetch.toString().length);
export default fetch;
readabilityHTTPProxy
@nbbaier
An interactive, runnable TypeScript val by nbbaier
HTTP
// @ts-expect-error
type Article = {
title: string;
content: string;
textContent: string;
length: number;
excerpt: string;
byline: string;
dir: string;
siteName: string;
instantDbTest
@yawnxyz
// ID for app: wonderful-wombat
Script
// ID for app: wonderful-wombat
const INSTANT_APP_ID = '39d1e341-f09a-4e77-8d5b-d368f65531b2';
const INSTANT_ADMIN_TOKEN = '86de53ab-eddb-4349-aed1-0665e55a74c0';
const db = init({
appId: INSTANT_APP_ID,
adminToken: INSTANT_ADMIN_TOKEN,
db?.transact(
tx?.messages?.[id()]?.update({
text: "banana!"
// // db.subscribeQuery({ todos: {} }, (resp) => {