Search

Results include substring matches and semantically similar vals. Learn more
stevekrouse avatar
openaistreaminghtml
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP
const openai = new OpenAI();
export default async (req) => {
const stream = await openai.chat.completions.create({
model: "gpt-3.5-turbo",
messages: [{
role: "user",
content: "an html page that contains a story. use tailwindcss for styling in the style of the story",
stream: true,
let { readable, writable } = new TransformStream();
let writer = writable.getWriter();
dhvanil avatar
val_4IiypjugcT
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_4IiypjugcT(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const isSimulation = () => {
const randomValue = Math.random();
return randomValue < 0.5; // 50% chance to simulate a simulation
return isSimulation();
// Return the result in a properly formatted response
return new Response(JSON.stringify({
dhvanil avatar
val_5OBYpMAcsJ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_5OBYpMAcsJ(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;
stevekrouse avatar
emojiExploder
@stevekrouse
@jsxImportSource npm:hono@3/jsx
HTTP
/** @jsxImportSource npm:hono@3/jsx */
const app = new Hono();
app.get("/", async (c) => {
return c.html(
<div>
<h1>Emoji exploder</h1>
<div>Enter an emoji and see what it's composed of</div>
<form action="/emoji" method="get">
<input type="text" name="emoji" /> <input type="submit" />
</form>
dhvanil avatar
val_4VZJ1Gz7nR
@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 });
ryanguill avatar
vibe_playground_upload
@ryanguill
An interactive, runnable TypeScript val by ryanguill
Script
export const vibe_playground_upload = () =>
new Response(
`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Upload PDF Page</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<style>
dhvanil avatar
val_wrXS4vL012
@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 });
dhvanil avatar
val_x1FBmxv9sD
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_x1FBmxv9sD(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const generateRandomNumbers = (count) => {
const numbers = [];
for (let i = 0; i < count; i++) {
numbers.push(Math.random());
return numbers;
const checkForPatterns = (numbers) => {
apitman avatar
decentauthdemo
@apitman
// export default handler;
HTTP
const prefix = "/login";
function html(userId, prefix) {
let content;
if (userId) {
content = `<h1>Hi there ${userId}</h1>\n<a href='${prefix}/logout'>Logout</a>`;
else {
content = `<h1>Hi there</h1>\n<a href='${prefix}'>Login</a>`;
return `
<!doctype html>
<html>
jollytoad avatar
helloWorld
@jollytoad
Hello world server, using http functions . Try hitting URLs such as: /world , /world.txt , /world.json , /world.html , or even /<script>.html . This demonstrates how you can import and compose simple functions to construct a router to route based on various aspects of a request, ie. the URL path, method, and even on media-types based on path extension or the Accept header. See routing functions , and response helpers on JSR. For a more detailed guide on building a Deno app, including things like fs based routing, with these fns see... https://jollytoad.deno.dev/blog/http_getting_started
HTTP
Hello world server, using [http functions](https://jsr.io/@http).
Try hitting URLs such as: [/world](https://jollytoad-helloworld.web.val.run/world), [/world.txt](https://jollytoad-helloworld
This demonstrates how you can import and compose simple functions to construct a router to route based on various aspects of
See [routing functions](https://jsr.io/@http/route), and [response helpers](https://jsr.io/@http/response) on JSR.
For a more detailed guide on building a Deno app, including things like fs based routing, with these fns see... https://jolly
export default handle([
byPattern(
"/:name{.:ext}?",
byMethod({
GET: byMediaType({
kajgod avatar
manage_users_js
@kajgod
An interactive, runnable TypeScript val by kajgod
Script
const js = `
let addOpen = false;
const addClass = " open";
const addButton = document.querySelector(".add-user_button");
const cancelButton = document.querySelector(".cancel-add-user");
const form = document.querySelector(".add-user_container");
const cancel = ()=>{
addOpen = !addOpen;
if(addOpen){
form.className = form.className + addClass;
iamseeley avatar
linkHandlers
@iamseeley
An interactive, runnable TypeScript val by iamseeley
Script
/** @jsx jsx */
/** @jsxFrag Fragment */
export const addLinkHandler = async (c) => {
try {
const payload = await c.get('jwtPayload');
const body = await c.req.parseBody();
const label = body.label;
const url = body.url;
if (!label || !url) {
return c.json({ error: 'Label and URL are required' }, 400);
adagradschool avatar
softTanSlug
@adagradschool
An interactive, runnable TypeScript val by adagradschool
HTTP
export default function handler(req) {
return new Response(`"\n <!DOCTYPE html>\n <html>\n <head>\n <title>Claude Chat Conversation</title
headers: {
"Content-Type": "text/html",
janpaul123 avatar
valle_tmp_68349873444339632722229399189495
@janpaul123
// This val responds with "Hello World" to all incoming HTTP requests with crazy CSS gradients
HTTP
// This val responds with "Hello World" to all incoming HTTP requests with crazy CSS gradients
export default async function main(req: Request): Promise<Response> {
const css = `
background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet);
font-size: 36px;
font-weight: bold;
text-align: center;
padding: 50px;
const html = `<div style="${css}">Hello World</div>`;
return new Response(html, { headers: { "Content-Type": "text/html" } });
tmcw avatar
ofScript
@tmcw
An interactive, runnable TypeScript val by tmcw
Script
addEventListener("htmx:pushedIntoHistory", (e) => {
for (const a of document.querySelectorAll("a")) {
a.classList.toggle("active", a.getAttribute("href") === e.detail.path);
addEventListener("keyup", (event) => {
const target = event.target;
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA") return;
if (event.key === "j" || event.key === "k") {
const next = document.querySelector(
event.key === "j"
? ".recipe.active + .recipe"