Search
HTTP_HelloWorld
@rozek
An interactive, runnable TypeScript val by rozek
HTTP
export default function (request: Request): Response {
return new Response("Hello world", {
headers: { "Content-Type": "text/plain" },
valshot
@burningion
Val Shot Generate val source code screenshot using sourcecodeshots.com ⚠️ This service is offered for personal use under a reasonable usage policy as stated here: https://sourcecodeshots.com/docs 📣 Special thanks to @pomdtr for their help and contributions! Usage https://vladimyr-valshot.web.val.run/v/<author>/<val> Example https://vladimyr-valshot.web.val.run/v/vladimyr/valshot https://vladimyr-valshot.web.val.run/v/pomdtr/readme
HTTP
return c.redirect(imageURL.href);
export default router.fetch;
export async function createScreenshot(code: string, theme: string = "dark-plus"): Promise<URL> {
const apiUrl = "https://sourcecodeshots.com/api/image/permalink";
const { url } = await ky.post(apiUrl, {
valle_tmp_7637538511907467267008900862313
@janpaul123
* Hacker News Clone (HTML frontend)
* This script sets up an HTTP Val to serve a simple HTML page that mimics Hacker News.
* The page contains static, fake example stories for now.
HTTP
* This script sets up an HTTP Val to serve a simple HTML page that mimics Hacker News.
* The page contains static, fake example stories for now.
export default async function(req: Request): Promise<Response> {
const htmlContent = `
<!DOCTYPE html>

retrieverSampleSelfQuery
@webup
An interactive, runnable TypeScript val by webup
Script
"npm:langchain/retrievers/self_query"
const { FunctionalTranslator } = await import(
"npm:langchain/retrievers/self_query/functional"
* First, we create a bunch of documents. You can load your own documents here instead.
* attributes you want to query on.
structuredQueryTranslator: new FunctionalTranslator(),
* Now we can query the vector store.

nominatimSearch
@mgruel
// Forked from @stevekrouse.nominatimSearch
Script
import { fetchJSON } from "https://esm.town/v/mgruel/fetchJSON";
export function nominatimSearch(params: {
q?: string;
street?: string;

fetch
@vladimyr
Proxied fetch - https://docs.val.town/std/fetch
Script
import { API_URL } from "https://esm.town/v/std/API_URL";
* Wraps the JavaScript Fetch function to anonymize where the request is
* coming from ([Docs ↗](https://docs.val.town/std/fetch))
* @param {string | URL | Request} input - The resource to fetch.
* @param {RequestInit} [requestInit] - Optional configuration data (HTTP
* method, headers, etc) ([Docs ↗](https://deno.land/api@v1.42.1?s=RequestInit))
export async function fetch(input: string | URL | Request, requestInit?: RequestInit) {
const origReq = new Request(input, requestInit);
const url = new URL("/v1/fetch", API_URL);
val_qTMN8anzhZ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_qTMN8anzhZ(req) {
try {
// Execute the code directly and capture its result
hi
@just_be
An interactive, runnable TypeScript val by just_be
HTTP
export default async function server(req: Request): Promise<Response> {
const html = `
<!DOCTYPE html>
buildagency
@elliotbraem
@jsxImportSource https://esm.sh/react
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
return (
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(
val_rSdr9CumnJ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function val_rSdr9CumnJ(req) {
try {
// Execute the code directly and capture its result
const result = await (async () => {
// Test for floating point precision anomalies
function testFloatingPointPrecision() {
const results = [];
// Test 1: Basic arithmetic that should equal 1

hardwarebingo
@stevekrouse
Hardware Startup 2024 Bingo Made with Claude Artifacts
HTTP
</div>
if (typeof document !== "undefined") { createRoot(document.getElementById("root")).render(<App />); }
export default async function(req: Request): Promise<Response> {
return new Response(
renderToString(

aquamarineShrimp
@cufaoil
An interactive, runnable TypeScript val by cufaoil
HTTP
export default async function(req: Request): Promise<Response> {
return Response.json({ address: "http://192.168.50.40:8080/event" });
altairClient
@flesch
Altair GraphQL Client import { altairClient } from "https://esm.town/v/flesch/altairClient";
import { graphql, GraphQLObjectType, GraphQLSchema, GraphQLString } from "https://esm.sh/graphql";
// Define the GraphQL schema
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: "Query",
fields: {
hello: {
type: GraphQLString,
resolve: () => "Hello from Val Town GraphQL API!",
},
},
}),
});
// Function to handle GraphQL requests
async function handleGraphQLRequest(request: Request): Promise<Response> {
const { query, variables } = await request.json();
const result = await graphql({
schema,
source: query,
variableValues: variables,
});
return new Response(JSON.stringify(result), {
headers: {
"Content-Type": "application/json"
},
});
}
// HTTP handler function
export default altairClient(async function(req: Request): Promise<Response> {
if (req.method === "POST") {
return handleGraphQLRequest(req);
} else {
return new Response("This endpoint only accepts POST requests for GraphQL queries.", { status: 405 });
}
}); ↑ https://www.val.town/v/flesch/graphqlAPIEndpoint
HTTP
resolve: () => "Hello from Val Town GraphQL API!",
// Function to handle GraphQL requests
async function handleGraphQLRequest(request: Request): Promise<Response> {
const { query, variables } = await request.json();
"Content-Type": "application/json"
// HTTP handler function
export default altairClient(async function(req: Request): Promise<Response> {
if (req.method === "POST") {
import { getDistDirectory, renderAltair, RenderOptions } from "npm:altair-static";
export function altairClient(next: (request: Request) => Response | Promise<Response>, options?: RenderOptions) {
return async (request: Request) => {
return next(request);
export default altairClient(async function(request: Request): Promise<Response> {
return new Response("Not found", { status: 404 });
sqliteWasm
@postpostscript
An interactive, runnable TypeScript val by postpostscript
Script
import { type InStatement, sqlite as sqliteAPI } from "https://esm.town/v/std/sqlite";
import { type ResultSet } from "npm:@libsql/client";
export function createSqlite() {
const db = new DB();
function execute(statement: InStatement): Omit<ResultSet, "columnTypes" | "lastInsertRowid"> {
const stmt = typeof statement === "string"
sql: statement,
valle_tmp_109048913203484876323222261393799
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
const SAMPLE_STORIES_KEY = "hn_realistic_sample_stories";
// Initialize sample stories and store them in blob storage
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {