1// This val will respond with a simple HTML form for users to input their name
2
3export default async function (req: Request): Promise<Response> {
4 if (req.method === "POST") {
5 const formData = new URLSearchParams(await req.text());
1// This val responds with an HTML form for users to input their name and get a greeting
2
3export default async function (req: Request): Promise<Response> {
4 // Reading form data if present
5 const formData = new URLSearchParams(await req.text());
1// This val will respond with an HTML greeting to any HTTP request
2
3export default async function (req: Request): Promise<Response> {
4 return new Response(`
5 <html>
1// This val will respond with "Hello, world!" to any HTTP request
2
3export default async function (req: Request): Promise<Response> {
4 return new Response("Hello, world!");
5}
1// This val will simply respond with "Hello, World!"
2export default async function(req: Request): Promise<Response> {
3 return new Response("Hello, World!");
4}
1// This val responds with "Hello, world!"
2export default async function(req: Request): Promise<Response> {
3 return new Response("Hello, world!");
4}
1// This val will respond with "Hello World" to any incoming HTTP request
2
3export default async function(req: Request): Promise<Response> {
4 return new Response("Hello World");
5}
4console.log(urls);
5
6export default async function scrapeWebsite(url: string) {
7 const response = await fetch(url);
8 const body = await response.text();
2
3// selects from xml selectors like <json></json> gets better results
4export function selectFromString(str, selector = "json", returnAll = false) {
5 const regex = new RegExp(`<${selector}>([\\s\\S]*?)</${selector}>`, 'gm');
6 const matches = [...str.matchAll(regex)].map(match => match[1]);
54
55// Render streaming markdown
56export default async function handler(req: Request): Promise<Response> {
57 let { readable, writable } = new TransformStream();
58 let writer = writable.getWriter();
Simple functional CSS library for Val Town
A helper function to build a file's email
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.