Search
val_v3yQtMfxD6
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_v3yQtMfxD6(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const calculateSqrt2 = (precision) => {
let low = 1;
let high = 2;
let mid;
for (let i = 0; i < precision; i++) {
mid = (low + high) / 2;
blobImages
@stevekrouse
Image downsizer and uploader
HTTP
# Image downsizer and uploader
/** @jsxImportSource npm:hono@3/jsx */
function esmTown(url) {
return fetch(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.142.86 Safari/537.36",
}).then(r => r.text());
const app = new Hono();
export default app.fetch;
wikitxt
@zokonil
An interactive, runnable TypeScript val by zokonil
Express (deprecated)
export const wikitxt = async (req: express.Request, res: express.Response) => {
console.log(JSON.stringify(req));
return res.json(req);
valle_tmp_6738558784733152514997198308998394
@janpaul123
// This val will serve an HTML page emulating a Hacker News clone.
HTTP
// This val will serve an HTML page emulating a Hacker News clone.
// It uses plain HTML and CSS to create the frontend. Links to stories will take you to pages with fake content.
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const stories = {
"first-fake-story": "This is the full content of the first fake story.",
"second-fake-story": "This is the full content of the second fake story.",
"third-fake-story": "This is the full content of the third fake story."
const storyKey = url.pathname.slice(1);
if (storyKey && stories[storyKey]) {
counter
@yawnxyz
// Export app.fetch for Val Town, otherwise export app ā this is only for hono apps
HTTP
const app = new Hono();
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="https://labspace.ai/ls2-circle.png" />
<title>Word Counter, Byte Counter, and Token Counter</title>
<meta property="og:title" content="Word Counter, Byte Counter, and Token Counter" />
valtownGeocities
@jamiedubs
attempt to generate websites using Glif and then store and publish them via Valtown - it's valtownGeocities! a real mouthful run this glif to generate HTML and publish to a given key: https://glif.app/@jamiedubs/glifs/clqecfqdd000tc3vk4i208jl3 access that website by going to a URL like: https://jamiedubs-valtownGeocities.web.val.run?key=YOURKEYHERE make sure to use the same key value for both the glif and to access your cool new website
HTTP
attempt to generate websites using [Glif](https://glif.app) and then store and publish them via Valtown - it's valtownGeocities! a real mouthful
- run this glif to generate HTML and publish to a given key: https://glif.app/@jamiedubs/glifs/clqecfqdd000tc3vk4i208jl3
- access that website by going to a URL like: https://jamiedubs-valtownGeocities.web.val.run?key=YOURKEYHERE
- make sure to use the same key value for both the glif and to access your cool new website
function isJSON(input: string | null | undefined) {
if (!input || input === null) return false;
try {
JSON.parse(input);
return true;
} catch (e) {
valle_tmp_75369426003016235227056957352348
@janpaul123
// This val will serve an HTML page emulating a Hacker News clone.
HTTP
// This val will serve an HTML page emulating a Hacker News clone.
// It uses plain HTML and CSS to create the frontend. Eventually,
// we can make it interactive with additional scripts.
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const pathname = url.pathname;
// If the user navigates to a specific story page
if (pathname.startsWith("/story/")) {
const storyId = pathname.split("/")[2];
return new Response(renderStoryPage(storyId), {
poebot
@jeffreyyoung
a simple poe bot
HTTP
a simple poe bot
// protocol https://creator.poe.com/docs/poe-protocol-specification
async function getResponse(req: any, send: (event: string, data?: any) => void) {
send("meta", { content_type: "text/markdown" });
send("text", { text: "```\n" + JSON.stringify(req, null, 3) + "\n```" });
send("done");
function encodeEvent(event: string, data?: any = {}) {
return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
export default async function(req: Request): Promise<Response> {
let timerId: number | undefined;
val_wLqQaKIA8e
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_wLqQaKIA8e(req) {
try {
// Create a function from the provided code and execute it
const userCode = async () => {
return const findPrimes = (n) => {
const primes = [];
for (let i = 2; i < n; i++) {
let isPrime = true;
for (let j = 2; j <= Math.sqrt(i); j++) {
if (i % j === 0) {
nimbleWhitePorpoise
@julianprincipe
An interactive, runnable TypeScript val by julianprincipe
HTTP
export default async function server(request: Request): Promise<Response> {
// Support GET, POST, and HEAD requests
if (request.method === "HEAD") {
// For HEAD requests, use URL search params
const url = new URL(request.url);
const text = url.searchParams.get('text');
// Validate that text is provided
if (!text) {
return new Response(null, {
status: 400,
honoJSX
@stevekrouse
@jsxImportSource https://esm.sh/hono@3.9.2/jsx
HTTP
/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
const Layout: FC = (props) => {
return (
<html>
<body>{props.children}</body>
</html>
const Top: FC<{ messages: string[] }> = (props: { messages: string[] }) => {
return (
<Layout>
<h1>Hello Hono!</h1>
valle_tmp_481955421792182202903467473951049
@janpaul123
// This val will respond to any request with an HTML "Hello, world!" message styled with fun CSS
HTTP
// This val will respond to any request with an HTML "Hello, world!" message styled with fun CSS
export default async function(req: Request): Promise<Response> {
const html = `
<html>
<head>
<style>
h1 {
color: #FF5733;
font-family: 'Comic Sans MS', cursive, sans-serif;
text-align: center;
val_wsOEr1WRVH
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_wsOEr1WRVH(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const multiply = (a, b) => a * b; return multiply(4, 7);
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
val_ZiSgmpYhg6
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
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
smurf
@tompatiger
An interactive, runnable TypeScript val by tompatiger
Script
export default async function server(request: Request): Promise<Response> {
const url = new URL(request.url);
const initialText = url.searchParams.get("text") || ""; // Get initial text from query param or default to empty
const processedSmurfText = smurfTransform(initialText); // Transform initial text if available
// Function to generate inline styles from the styles object
const generateStyles = (styles) => {
let styleString = "";
for (const [key, value] of Object.entries(styles)) {
styleString += `${key}: ${value}; `;
return styleString;