Search

Results include substring matches and semantically similar vals. Learn more
dhvanil avatar
val_fM7f5WnH8f
@dhvanil
An interactive, runnable TypeScript val by dhvanil
Script
export default async function handler(req) {
try {
return Response.json({ success: true });
} catch (error) {
return Response.json({
success: false,
error: error.message,
}, { status: 500 });
dhvanil avatar
val_k3bnEl3RRg
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_k3bnEl3RRg(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const checkMathConsistency = () => {
const a = 10;
const b = 5;
const expectedResults = {
addition: a + b,
subtraction: a - b,
slade avatar
expressHTMLExample
@slade
An interactive, runnable TypeScript val by slade
Script
export async function expressHTMLExample(req, res) {
return res.send(`<h1>Hi ${req.query.name || req.body.name}!</h1>`);
tmcw avatar
blocks_inner
@tmcw
An interactive, runnable TypeScript val by tmcw
Express (deprecated)
export let blocks_inner = async (req, res) => {
const [_, user, id, ...file] = req.path.split("/");
const gist = await fetch(`https://api.github.com/gists/${id}`).then((r) =>
r.json()
res.set("Cache-Control", "public,max-age=64800");
if (file.filter(Boolean).length) {
if (gist.files[file.filter(Boolean).join("/")].raw_url.endsWith(".js")) {
res.set("Content-Type", "application/javascript");
return res.send(
await fetch(gist.files[file.filter(Boolean).join("/")].raw_url).then(
adagradschool avatar
openPurpleHippopotamus
@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",
dhvanil avatar
val_0eoDqjj87h
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_0eoDqjj87h(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const calculatePi = (iterations) => {
let pi = 0;
let divisor = 1;
for (let i = 0; i < iterations; i++) {
pi += (i % 2 === 0 ? 1 : -1) / divisor;
divisor += 2;
dhvanil avatar
val_282e3mL94A
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_282e3mL94A(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const fibonacci = (n) => {
if (n <= 1) return n;
let a = 0, b = 1, temp;
for (let i = 2; i <= n; i++) {
temp = a + b;
a = b;
janpaul123 avatar
valle_tmp_223639413409153054546235403778147
@janpaul123
// This val will respond with a colorful "Hello World" HTML page with fun CSS styling
HTTP
// This val will respond with a colorful "Hello World" HTML page with fun CSS styling
export default async function(req: Request): Promise<Response> {
// HTML content with fun CSS styling
const htmlContent = `
<html>
<head>
<style>
body {
background: linear-gradient(to right, #ff00a3, #D000FF);
font-family: 'Comic Sans MS', cursive, sans-serif;
yawnxyz avatar
openAIHonoChatStreamExample
@yawnxyz
Example of using Hono to stream OpenAI's streamed chat responses!
HTTP
Example of using Hono to stream OpenAI's streamed chat responses!
const app = new Hono();
const openai = new OpenAI();
app.use('*', cors({
origin: '*',
allowMethods: ['GET'],
allowHeaders: ['Content-Type'],
// Set CORS and headers for SSE
app.use('/chat, /chat/*', async (c, next) => {
c.header('Content-Type', 'text/event-stream');
janpaul123 avatar
valle_tmp_781813510392997339362721755947017
@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: #FF6347;
font-family: 'Comic Sans MS', cursive, sans-serif;
</style>
youtubefree avatar
solicitousAmethystMeadowlark
@youtubefree
An interactive, runnable TypeScript val by youtubefree
HTTP
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Headers": "*",
status: 204,
const openai = new OpenAI();
try {
var body = await req.json();
dhvanil avatar
val_wzsgIq92EP
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_wzsgIq92EP(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Create a mermaid diagram analyzing potential surveillance devices
const diagram = `
graph TD
A[Simulation Prison] --> B[Surveillance Devices]
B --> C[Vending Machines]
B --> D[Plants]
janpaul123 avatar
valle_tmp_679889573882008811461733353061443
@janpaul123
This code sets up a simple comment box system with Tailwind CSS styling for a prettier interface. * Leverages Deno's blob storage for persistence, * Renders an HTML form to accept new comments, * and displays all existing comments.
HTTP
/** This code sets up a simple comment box system with Tailwind CSS styling for a prettier interface.
* Leverages Deno's blob storage for persistence,
* Renders an HTML form to accept new comments,
* and displays all existing comments.
// Key for blob storage
const COMMENTS_KEY = "comments_storage";
// HTML template for the form and comments list
const getHtml = (comments: string[]) => `
<!DOCTYPE html>
<html lang="en">
andreterron avatar
helloexpress
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
export let helloexpress = (req, res) => res.send("Hello Andre!");
ryanwaits avatar
satsNameApi
@ryanwaits
An interactive, runnable TypeScript val by ryanwaits
HTTP
export const satsNameApi = async (req: Request) => {
const { Hono } = await import("npm:hono");
const app = new Hono();
let events = [];
app.post("/api/events", async (c) => {
const body = await c.req.json();
const { apply } = body;
let events = [];
apply.forEach((item: any) => {
item.transactions.forEach((transaction: any) => {