9 * @param val Define which val should open. Defaults to the root reference
10 */
11export function modifyHtmlString(
12 bodyText: string,
13 { val, style }: { val?: ValRef; style?: string } = {},
40 * @param val Define which val should open
41 */
42export function modifyFetchHandler(
43 handler: (req: Request) => Response | Promise<Response>,
44 { val, style }: { val?: ValRef; style?: string } = {},
34const resultCache = new Map();
35
36export default async function server(request: Request): Promise<Response> {
37 if (request.method === "GET") {
38 return new Response(html, {
171const openai = new OpenAI();
172
173async function getEmbeddings(texts) {
174 const response = await openai.embeddings.create({
175 model: "text-embedding-ada-002",
203
204 <script>
205 function runDemo() {
206 const testData = {
207 embeddings: Array.from({length: 100}, () => Array.from({length: 10}, () => Math.random())),
4import type { User } from "https://esm.town/v/stevekrouse/zod_demo_shared";
5
6export function App() {
7 const [user, setUser] = useState<User>({ username: "", email: "", age: 0 });
8 const [errors, setErrors] = useState<Partial<User>>({});
2import { UserSchema } from "https://esm.town/v/stevekrouse/zod_demo_shared";
3
4async function server(request: Request): Promise<Response> {
5 if (request.method === "POST" && new URL(request.url).pathname === "/register") {
6 try {
31console.log(text);
32
33export async function weatherGPT() {
34 await email({ subject: "Weather Today", text });
35}
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "downtown brooklyn"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });
82});
83
84export default async function server(req: Request): Promise<Response> {
85 return app.fetch(req);
86}
141. The application uses the Hono framework to create a simple web server.
152. HTMX is used for handling AJAX requests without writing JavaScript.
163. Alpine.js provides reactivity for the clipboard functionality.
174. The Turndown library is used to convert HTML to Markdown.
18
1/**
2 * This val creates an email storage system using SQLite.
3 * It stores each email sent through the 'newsly' function into a SQLite database.
4 * The email address of the sender is used as the key.
5 * We'll use the sqlite module for database operations and the email module for sending emails.
9
10
11export async function newsly2(e: {
12 from: string;
13 to: string[];
8};
9
10export async function sendSMS(phoneNumber: string, message: string, carrier: string): Promise<void> {
11 const carrierDomain = carriers[carrier.toLowerCase()];
12 if (!carrierDomain) {
22 text: message,
23 });
24 console.log('Email function returned:', result);
25 console.log('SMS sent successfully');
26 } catch (error) {
A helper function to build a file's email
Simple functional CSS library for Val Town
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.