Search

Results include substring matches and semantically similar vals. Learn more
jessmartin avatar
browserlessScrapeExample
@jessmartin
An interactive, runnable TypeScript val by jessmartin
Script
export const browserlessScrapeExample = (async () => {
const res = await fetch(
`https://chrome.browserless.io/screenshot?token=${process.env.browserlessKey}`,
method: "POST",
body: JSON.stringify({
"url": "https://jessmartin-htmlHandler.express.val.run",
"options": {
"clip": {
"x": 0,
"y": 0,
janpaul123 avatar
valle_tmp_50449610377968496666839612547843
@janpaul123
// This val serves an HTML page emulating a Hacker News clone.
HTTP
// This val serves an HTML page emulating a Hacker News clone.
// Titles are clickable and lead to a page with fake story content.
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const pathname = url.pathname;
if (pathname === "/story1") {
return Response.json({
title: "First Fake Story",
content: `
<h2>First Fake Story</h2>
nbbaier avatar
dbToAPI
@nbbaier
Create an API from a lowdb blob This val exports a function that takes a lowdb instance and returns a Hono router that can be used to interact with the data. This is the beginning of an implementation of something like json-server for Val Town. The resulting server also comes with a frontend at / . The code for the frontend can be found here . See this val for an example. Things I'd like to implement All HTTP methods Custom route definitions (like in json-server ) Custom frontends Filtering, sorting, pagination, etc
Script
## Create an API from a [lowdb blob](https://www.val.town/v/pomdtr/lowdb)
This val exports a function that takes a lowdb instance and returns a [Hono](https://hono.dev) router that can be used to int
The resulting server also comes with a frontend at `/`. The code for the frontend can be found [here](https://www.val.town/v/
See [this val](https://www.val.town/v/nbbaier/dbToAPIexample) for an example.
### Things I'd like to implement
- All HTTP methods
/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/
// TODO: implement options
export async function createServer(db, options: Options & { auth?: { username: string; password: string } } = {}) {
const app = new Hono();
envl avatar
anyjs
@envl
An interactive, runnable TypeScript val by envl
Script
export async function anyjs(req: Request) {
// const res = await @stevekrouse.eval_("8+8");
return Response.json(Array.from(req.headers.entries()));
// @stevekrouse.xeval
taras avatar
fireworks_ai_proxy
@taras
HTTP
const COMPLETION = "/chat/completions";
const MODELS = "/models";
const supported_urls = [COMPLETION, MODELS];
// Define a common set of CORS headers
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "*",
function err(msg): Response {
return new Response(
stevekrouse avatar
viewSource
@stevekrouse
View source code Just like a right click + inspect on desktop, except available on mobile too! https://stevekrouse-viewsource.web.val.run/?url=https://www.todepond.com/wikiblogarden/tadi-web/lab/counter/
HTTP
# View source code
Just like a right click + inspect on desktop, except available on mobile too!
https://stevekrouse-viewsource.web.val.run/?url=https://www.todepond.com/wikiblogarden/tadi-web/lab/counter/
export default modifyFetchHandler(async function(req: Request) {
const pathname = new URL(req.url).searchParams.get("url");
const html = await fetchText(pathname ?? "example.com"); // .then(prettifyHtml);
const body = `<html>
<head>
<script
type="module"
pperi avatar
compactAmberMongoose
@pperi
Blob Admin This is a lightweight Blob Admin interface to view and debug your Blob data. Use this button to install the val: It uses basic authentication with your Val Town API Token as the password (leave the username field blank). TODO [x] /new - render a page to write a new blob key and value [x] /edit/:blob - render a page to edit a blob (prefilled with the existing content) [x] /delete/:blob - delete a blob and render success [x] add upload/download buttons [ ] Use modals for create/upload/edit/view/delete page (htmx ?) [ ] handle non-textual blobs properly [ ] use codemirror instead of a textarea for editing text blobs
HTTP
# Blob Admin
This is a lightweight Blob Admin interface to view and debug your Blob data.
![b7321ca2cd80899250589b9aa08bc3cae9c7cea276282561194e7fc537259b46.png](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/311a
Use this button to install the val:
[![](https://stevekrouse-button.express.val.run/Install)](https://www.val.town/v/stevekrouse/blob_admin_app/fork)
It uses [basic authentication](https://www.val.town/v/pomdtr/basicAuth) with your [Val Town API Token](https://www.val.town/s
/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
test(() => {
expect(view_route).toBeTruthy();
expect(create_route).toBeTruthy();
stevekrouse avatar
lastlogin_safe
@stevekrouse
Cross-platform safe Last Login Middleware This is a pretty ugly sittuation. It's really a hack around the way @stevekrouse/lastlogin was written, but to make it safe to import on the frontend, because it only imports the backend stuff dynamically per request.
Script
# Cross-platform safe Last Login Middleware
This is a pretty ugly sittuation. It's really a hack around the way @stevekrouse/lastlogin was written, but to make it safe t
export const lastlogin = (handler) => (async (req) => {
const { lastlogin } = await import("https://esm.town/v/stevekrouse/lastlogin");
return lastlogin(handler)(req);
dhvanil avatar
val_Klwooy8Rwj
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_Klwooy8Rwj(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
const checkAnomalies = () => {
const expectedRange = [0, 100];
const randomValue = Math.random() * 100;
return randomValue < expectedRange[0] || randomValue > expectedRange[1] ? 'Anomaly detected!' : 'No anomalies.';
checkAnomalies();
// Return the result in a properly formatted response
dhvanil avatar
val_aDf4PZkyzz
@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 });
dhvanil avatar
val_tlShmRkTZo
@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 });
pomdtr avatar
ninja_keys
@pomdtr
GET https://pomdtr-ninja_keys.web.val.run
HTTP
```http
GET https://pomdtr-ninja_keys.web.val.run
/** @jsxImportSource npm:hono@3.12.8/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" />
stevekrouse avatar
lastlogin_demo
@stevekrouse
HTTP
![Screenshot 2024-08-08 at 08.48.41.gif](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/7442086d-36b2-454d-bd5f-3c28615e900
/** @jsxImportSource npm:hono@3/jsx */
const app = new Hono();
app.get("/", (c) => {
const email = c.req.header("X-LastLogin-Email");
if (email) {
return c.html(
<div>
<h1>Welcome, {email}!</h1>
<a href="/auth/logout">Logout</a>
janpaul123 avatar
valle_tmp_272587506760611838217863338600184
@janpaul123
// Respond with fun HTML content and silly gradients on every HTTP request
HTTP
// Respond with fun HTML content and silly gradients on every HTTP request
export default async function(req: Request): Promise<Response> {
const htmlContent = `
<html>
<head>
<style>
body {
background: linear-gradient(to right, #ff758c, #ff7eb3);
font-family: Arial, sans-serif;
text-align: center;
dhvanil avatar
web_sSNxaja4bH
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_sSNxaja4bH(req) {
return new Response(`<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Retro Space Interface</title>
<style>
body {
margin: 0;