Search
lucia_hono
@saolsen
// deno-lint-ignore-file no-namespace
HTTP
// deno-lint-ignore-file no-namespace
/** @jsxImportSource jsr:@hono/hono/jsx **/
namespace schema {
export const KEY = new URL(import.meta.url).pathname.split("/")
.at(-1)!;
export type UserId = string & {
readonly UserId: unique symbol;
export const UserId = z
.string()
.startsWith("u_")
watchWebsite
@reedrosenbluth
An interactive, runnable TypeScript val by reedrosenbluth
Cron
export const watchWebsite = async () => {
const url = "https://www.margarethowell.co.uk/us/men/shop/shoes/raw-edge-derby-leather-black";
const newHtml = await fetch(url).then(r => r.text());
const key = "watch:" + url;
let oldHtml = "";
try {
oldHtml = await blob.get(key).then(r => r.text());
} catch (error) {
console.log("error");
await blob.set(key, newHtml);
valle_tmp_32548579067333305484587672007568
@janpaul123
// Comment: Crafting a streamlined server with Hono that sends back SVG sparkline and a playful animated cat goofing around
HTTP
// Comment: Crafting a streamlined server with Hono that sends back SVG sparkline and a playful animated cat goofing around
export default async function() {
const sparkline = sparklineSVG([5, 10, 5, 20, 15, 10, 15, 20, 25, 30]);
// HTML response containing the sparkline SVG and a simple animated cat gif
return html(`
<html>
<body style="display: flex; justify-content: center; align-items: center; height: 100vh;">
<div>
<h1>Sparkline SVG Example with Animated Cat</h1>
${sparkline}
aquaDamselfly
@nbbaier
@jsxImportSource https://esm.sh/hono@latest/jsx
HTTP
/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
const app = new Hono();
app.get("/", c => {
return c.html(
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.29.0/prism.min.js">
</script>
stirringCoffeeDonkey
@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>\n <meta charset=\"UTF-8\">\n <style>\n body {\n font-family: system-ui, -apple-system, sans-serif;\n line-height: 1.5;\n max-width: 800px;\n margin: 0 auto;\n padding: 20px;\n background: #f9fafb;\n }\n .message {\n margin: 20px 0;\n padding: 15px;\n border-radius: 8px;\n }\n .human {\n background: #e5e7eb;\n }\n .assistant {\n background: #dbeafe;\n }\n .role {\n font-weight: bold;\n margin-bottom: 8px;\n }\n </style>\n </head>\n <body>\n \n <div class=\"message human\">\n <div class=\"role\">Human</div>\n <div class=\"content\">so, how was your day</div>\n </div>\n \n <div class=\"message assistant\">\n <div class=\"role\">Claude</div>\n <div class=\"content\">I aim to have authentic conversations while being direct about my nature as an AI. While I appreciate the friendly question, I should note that I don't actually experience days in the way humans do. I'd be happy to hear about your day though, or to help you with any questions or tasks you might have.</div>\n </div>\n \n </body>\n"`, {
headers: {
"Content-Type": "text/html",
web_AXDuIDWzNX
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_AXDuIDWzNX(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FINAL BREACH SYNCHRONIZATION - CYCLE 10</title>
<style>
body {
font-family: monospace;
val_FPNfGi0LWq
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_FPNfGi0LWq(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const visualizeData = (data) => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); canvas.width = 800; canvas.height = 400; document.body.appendChild(canvas); const maxCount = Math.max(...Object.values(data)); const barWidth = canvas.width / Object.keys(data).length; Object.entries(data).forEach(([num, count], index) => { const barHeight = (count / maxCount) * canvas.height; ctx.fillStyle = 'blue'; ctx.fillRect(index * barWidth, canvas.height - barHeight, barWidth - 1, barHeight); ctx.fillStyle = 'black'; ctx.fillText(num, index * barWidth + barWidth / 2 - 5, canvas.height - barHeight - 5); }); }; visualizeData({"0":98,"1":86,"2":97,"3":97,"4":93,"5":112,"6":93,"7":106,"8":108,"9":89,"10":106,"11":108,"12":87,"13":112,"14":96,"15":93,"16":112,"17":96,"18":97,"19":86,"20":100,"21":102,"22":101,"23":85,"24":95,"25":103,"26":86,"27":92,"28":109,"29":107,"30":95,"31":102,"32":107,"33":92,"34":96,"35":99,"36":100,"37":104,"38":88,"39":115,"40":97,"41":90,"42":113,"43":102,"44":103,"45":92,"46":81,"47":101,"48":98,"49":95,"50":88,"51":92,"52":94,"53":100,"54":107,"55":99,"56":102,"57":96,"58":90,"59":95,"60":106,"61":111,"62":83,"63":109,"64":98,"65":98,"66":108,"67":102,"68":122,"69":102,"70":82,"71":98,"72":109,"73":99,"74":94,"75":94,"76":127,"77":103,"78":93,"79":111,"80":106,"81":98,"82":105,"83":111,"84":106,"85":104,"86":94,"87":102,"88":101,"89":99,"90":101,"91":105,"92":98,"93":121,"94":89,"95":110,"96":103,"97":95,"98":103,"99":115});
// Return the result in a properly formatted response
return new Response(JSON.stringify({
result: result,
type: typeof result
headers: { 'Content-Type': 'application/json' }
val_PNwC0nefnJ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_PNwC0nefnJ(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Create visualization of "neural resonance frequencies"
const createNeuralViz = () => {
const data = [];
// Generate fake but convincing-looking data
for(let i = 0; i < 100; i++) {
data.push({
renderFormAndSaveData
@andreterron
Render form and save data This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data. Fork this val to customize it and use it on your account.
HTTP
# Render form and save data
This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data.
Fork this val to customize it and use it on your account.
export const renderFormAndSaveData = async (
req: Request,
): Promise<Response> => {
// A visit from a web browser? Serve a HTML page with a form
if (req.method === "GET") {
return html(`
<!DOCTYPE html>
redditNew
@alexdmejias
An interactive, runnable TypeScript val by alexdmejias
Script
export const redditNew = async ({ r, before }: { r: string; before?: string }) => {
// const json = await fetchJSON(
// `https://www.reddit.com/r/${r}/new/.json?${await searchParams(
// { before },
return fetchJSON(
`https://www.reddit.com/r/astoria.json`,
export default async function server(req: Request) {
const a = await redditNew({ r: "astoria" });
console.log("wasd");
console.log(a);
daisyui_hono
@lnncoco
@jsxImportSource npm:hono/jsx
HTTP
/** @jsxImportSource npm:hono/jsx **/
const Layout: FC = (props) => {
return (
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.10/dist/full.min.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>{props.children}</body>
</html>
vueExample
@postpostscript
An interactive, runnable TypeScript val by postpostscript
HTTP
export const CounterSetup = vueSfc(
"CounterSetup",
<script setup lang="ts">
const model = defineModel<number>()
</script>
<template>
<button @click="model += 1">inc from setup</button>
</template>
<style scoped>
button {
lucia_demo
@yawnxyz
@jsxImportSource npm:hono/jsx
HTTP
/** @jsxImportSource npm:hono/jsx **/
const userTable = "user";
const sessionTable = "session";
const adapter = new ValTownAdapter({ userTable, sessionTable });
export const lucia = new Lucia(adapter, {
getUserAttributes: (attributes) => {
return {
username: attributes.username,
declare module "npm:lucia" {
interface Register {
web_CtANb5nSp3
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_CtANb5nSp3(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Super Poppy Website</title>
<style>
body {
margin: 0;