Search

Results include substring matches and semantically similar vals. Learn more
gregplumbly avatar
myApi
@gregplumbly
An interactive, runnable TypeScript val by gregplumbly
Script
export function myApi(name) {
return "hi " + name;
prepor avatar
pingMe
@prepor
An interactive, runnable TypeScript val by prepor
Script
let { incrementer } = await import("https://esm.town/v/prepor/incrementer");
export function pingMe() {
incrementer += 1;
console.email(`How are you? ${incrementer}`);
stevekrouse avatar
geocode
@stevekrouse
* This code creates a geocoder widget similar to the Google Maps API search widget. * It uses React for the frontend, the Cerebras API for LLM-based geocoding, * and Leaflet for displaying the map.
HTTP
import debounce from "https://esm.sh/lodash.debounce";
function App() {
const [query, setQuery] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
async function server(request: Request): Promise<Response> {
if (request.method === "POST" && new URL(request.url).pathname === "/geocode") {
} catch (error) {
console.error("Error calling Cerebras API:", error);
return new Response(JSON.stringify({ error: "Failed to fetch suggestions" }), {
nik avatar
myApi
@nik
An interactive, runnable TypeScript val by nik
Script
export function myApi(name) {
return "hi " + name;
heltonteixeira avatar
MicroSaasIdeaRoulette
@heltonteixeira
@jsxImportSource https://esm.sh/react
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [idea, setIdea] = useState("Spin to get a MicroSaaS idea!");
const [isSpinning, setIsSpinning] = useState(false);
async function generateIdea() {
setIsSpinning(true);
display: 'block',
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
// Handle idea generation endpoint
try {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const completion = await openai.chat.completions.create({
messages: [
simonharrisco avatar
ping2
@simonharrisco
An interactive, runnable TypeScript val by simonharrisco
Cron
import { fetchHTML } from "https://esm.town/v/stevekrouse/fetchHTML?v=9";
export function ping2() {
fetchHTML("https://simonharrisco-site.vercel.app/");
z233 avatar
expressApiTest
@z233
An interactive, runnable TypeScript val by z233
Script
export function expressApiTest(req: express.Request, res: express.Response) {
function listAllMembers(obj) {
const members = new Set();
let currentObject = obj;
JoeB avatar
myApi
@JoeB
An interactive, runnable TypeScript val by JoeB
Script
export function myApi(name) {
return "hi " + name;
yawnxyz avatar
lunrSearchDemo
@yawnxyz
A very simple demo of lunr, an in-memory text search that's perfect for Valtown
Script
import lunr from 'https://cdn.skypack.dev/lunr';
const idx = lunr(function () {
this.field('content');
this.add({ id: 1, content: 'Banana Apples and Oranges' });
rozek avatar
GDI_URLParserService
@rozek
This val is part of a series of examples to introduce "val.town" in my computer science course at Stuttgart University of Applied Sciences . The idea is to motivate even first-semester students not to wait but to put their ideas into practice from the very beginning and implement web apps with frontend and backend. It contains a very simple HTTP end point which extracts the URL path (after the val base URL) and any query/search parameters. In contrast to some other solutions (including the one suggested by Townie), this code takes into account that query parameters may appear multiple times in order to represent a list of values. In order to use it, send a request similar to the following https://rozek-gdi_urlparserservice.web.val.run/url/path?bool=true&number=3.14&string=text&list=false&list=2,72&list="hi!" The code was created using Townie - with only a few small manual corrections. This val is licensed under the MIT License.
HTTP
export default async function(req: Request): Promise<Response> {
const url = new URL(req.url);
const path = url.pathname;
nbbaier avatar
dbToApiHelpers
@nbbaier
Helper functions/types for Val Town JSON Server
Script
Helper functions/types for [Val Town JSON Server](https://www.val.town/v/nbbaier/dbToAPI)
carissacha avatar
roseGull
@carissacha
// Fetches a random joke.
Script
// Fetches a random joke.
function fetchRandomJoke() {
const response = fetch(
return response;
function fetchRandomJoke() {
const SAMPLE_JOKE = {
// Fetches a random joke.
function fetchRandomJoke() {
const SAMPLE_JOKE = {
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
pomdtr avatar
val_town_client
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
import { paths } from "https://esm.town/v/pomdtr/openapi_schema";
import createClient2 from "npm:openapi-fetch";
export default function createClient(options?: {
baseUrl?: string;
token?: string;
rozek avatar
GDI_AITranslator
@rozek
This val is part of a series of examples to introduce "val.town" in my computer science course at Stuttgart University of Applied Sciences . The idea is to motivate even first-semester students not to wait but to put their ideas into practice from the very beginning and implement web apps with frontend and backend. It contains a simple web page which allows users to enter some german (or other non-english) text and send it to a preconfigured server. That server translates the text with the help of OpenAI and sends the result back to this app where it is finally presented to the user. This val is the companion of https://rozek-gdi_aitranslatorservice.web.val.run/ which contains the server part (aka "backend") for this example. The code was created using Townie - with only a few small manual corrections. This val is licensed under the MIT License.
HTTP
non-english) text and send it to a preconfigured server. That server translates
the text with the help of OpenAI and sends the result back to this app where it
is finally presented to the user.
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
const [germanText, setGermanText] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
client();
export default async function server(request: Request): Promise<Response> {
return new Response(
justwph avatar
myApi
@justwph
An interactive, runnable TypeScript val by justwph
Script
export function myApi(name) {
return "hi " + name;