2// Click "Run", copy and paste the email address and send an email to it.
3// This example will log the email details received.
4export default async function emailHandler(email: Email){
5 console.log("Email received!", email.from, email.subject, email.text);
6 for (const file of email.attachments) {
2// Configure the timer with the 🕒 icon in the top right.
3// This example just logs the current time.
4export function scheduledHandler() {
5 const timestamp = new Date().toISOString();
6 console.log(`Cron val executed at: ${timestamp}`);
2// Access it via its public URL (you can also pick a nicer subdomain).
3// Try adding ?name=YourName to the URL!
4export default function httpHandler(req: Request): Response {
5 const url = new URL(req.url);
6 const name = url.searchParams.get("name") || "Friend";
1// This script returns a random fun fact
2// You can run scripts manually in this view or call it from other vals.
3export default function getRandomFact() {
4 const funFacts = [
5 "Honey never spoils.",
1export default async function(req: Request): Promise<Response> {
2 for await (const { isFile, name } of Deno.readDir("."))
3 console.log(name);
106 const defaultNS = xmlDoc.documentElement.namespaceURI;
107
108 // Custom namespace resolver function for XPath
109 function lookupNamespace(prefix) {
110 if (prefix === 'h') return defaultNS; // HL7 namespace
111 if (prefix === 'xsi') return 'http://www.w3.org/2001/XMLSchema-instance';
1export function readFileSync(path: string, options?: string | { encoding?: string; flag?: string }): string | Buffer {
2 console.log(`Mock readFileSync called for: ${path}`);
3 return "hello";
1export default async function(interval: Interval) {
2 console.log(interval);
3}
1import fs from "node:fs";
2
3export function readTest() {
4 const data = fs.readFileSync("test", "utf8");
5 console.log(data);
186
187// Modal Hook
188export function useModal() {
189 const [isOpen, setIsOpen] = React.useState(false);
190
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.