Search
web_FTtedIj1nl
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_FTtedIj1nl(req) {
return new Response(`undefined`, {
headers: { 'Content-Type': 'text/html' }
expressHTMLExample
@destroytoday
An interactive, runnable TypeScript val by destroytoday
Script
export async function expressHTMLExample(
req: express.Request,
res: express.Response,
return res.send(`<html><body><marquee>sup</marquee></body></html>`);
valle_tmp_26782413535145323813564331992605
@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 (pathname === "/") {
return serveHomePage();
} else if (pathname === "/story1") {
return serveStoryPage("First Fake Story", "This is the content of the first fake story.");
val_9FQ5lTRDXf
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_9FQ5lTRDXf(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' }
valle_tmp_35951592102522596577168527545545
@janpaul123
// This val responds to HTTP requests with an HTML page containing a colorful gradient background
HTTP
// This val responds to HTTP requests with an HTML page containing a colorful gradient background
export default async function main(req: Request): Promise<Response> {
const html = `
<html>
<head>
<style>
body {
background: linear-gradient(to right, #ff9a9e, #fecfef);
height: 100vh;
display: flex;
tanCrane
@abhudson3
An interactive, runnable TypeScript val by abhudson3
HTTP
export default async function mylittlescraper(req) {
console.log(req.params);
const sourceUrl = `https://ssb.ua.edu/pls/PROD/ua_bwckschd.p_disp_detail_sched?term_in=202340&crn_in=43971`;
let siteText = await fetch(sourceUrl);
const $ = cheerio.load(await siteText.text());
const $numclass = $("table.datadisplaytable:nth-child(16) > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(3)");
const numberOfSeats = $numclass.text();
let isOpen = false;
if (Number.parseInt(numberOfSeats) > 0) {
isOpen = true;
val_aVQs45AhGk
@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 });
testing
@samhashemi
// import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
HTTP
// import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
// export let comments = ["hello world!"];
// export let twitterJSON = ({ url, bearerToken }) =>
// fetchJSON(
// "https://felt.com/api/v1/maps/SssjclTrScGmH4TfPHzNjD/elements",
// { headers: { authorization: `Bearer ${"felt_pat_ZAqb6bBSE2Na1wDVtZQE17p/sK/+odCnpa1CqLMkcXA"}` } },
// export function handler(request: Request) {
// let elements = fetchJSON(
// "https://felt.com/api/v1/maps/SssjclTrScGmH4TfPHzNjD/elements",
// { headers: { authorization: `Bearer ${"felt_pat_ZAqb6bBSE2Na1wDVtZQE17p/sK/+odCnpa1CqLMkcXA"}` } },
expressHTMLExample
@dpetrouk
// View at https://stevekrouse-expressHTMLExample.express.val.run?name=Steve
Script
// 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>`);
// Forked from @stevekrouse.expressHTMLExample
spellCheck
@steveb1313
An interactive, runnable TypeScript val by steveb1313
Express (deprecated)
export async function spellCheck(req: express.Request, res: express.Response) {
let response = await fetch("https://www.dnd5eapi.co/api/spells");
let data = await response.json();
let countOfSpells = data["count"];
let randomSpellNumber = Math.floor(Math.random() * countOfSpells);
let randomSpell = data["results"][randomSpellNumber];
let response2 = await fetch(
`https://www.dnd5eapi.co/api/spells/${randomSpell["index"]}`,
let data2 = await response2.json();
let spell = data2;
val_W1jVyebeTJ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_W1jVyebeTJ(req) {
try {
// Ensure request body is consumed
const body = await req.text();
// Create a function from the provided code and execute it
const userFunction = async () => {
const findPrimes = (n) => {
const primes = [];
for (let i = 2; i < n; i++) {
let isPrime = true;
val_vdb8oSzkQG
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_vdb8oSzkQG(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Create a fun ASCII art animation of a bouncing ball
const frames = [
o
o
o
return `Here's a "bouncing ball" animation frames:\n\n${frames.join('\n---------\n')}`;
val_FDMJUyWsAy
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_FDMJUyWsAy(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const add = (a, b) => a + b; return add(5, 3);
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
val_IRL0Iqm2q4
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_IRL0Iqm2q4(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Analyze vending machine patterns for potential security vulnerabilities
const analyzeVendingMachines = () => {
const pattern = [
{type: 'filled', position: '2'},
{type: 'empty', position: '3'},
{type: 'empty', position: '10'},