2import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
3
4export async function dailyDadJoke() {
5 let { setup, punchline } = await fetchJSON("https://official-joke-api.appspot.com/random_joke");
6 return email({
1# Render form and save data
2
3This val provides a web-based interface for collecting email addresses. It features a dual-functionality approach: when accessed via a web browser using a GET request, it serves an HTML form where users can submit their email address. If the script receives a POST request, it implies that the form has been submitted, and it proceeds to handle the incoming data.
4
5Fork this val to customize it and use it on your account.
1export function h2(value) { return `<h2>${value}</h2>`; }
2export function li(value) { return `<li>${value}</li>`; }
3export function td(value) { return `<td>${value}</td>`; }
4export function th(value) { return `<th>${value}</th>`; }
5export function tr(...cells) { return `<tr>${cells.join('')}</tr>`; }
6export function ul(...items) { return `<ul>${items.join('')}</ul>`; }
7export function table(...items) { return `<table>${items.join('')}</table>`; }
8export function bordered(...items) { return `<table border>${items.join('')}</table>`; }
9export function a(href,label) { return `<a href="${href}">${label}</a>`; }
10export function download(label,href,filename) { return `<a href="${href}" download="${filename}">${label}</a>`; }
11export function img(src) { return `<img src="${src}" alt="photo for ${src}" width="100">`}
12export function p(value) { return `<p>${value}</p>`; }
13export function pre(value) { return `<pre>${value}</pre>`; }
14export function details(summary,details) { return `<details><summary>${summary}</summary>${details}</details>`; }
15export function html(...items) { return `<!DOCTYPE html><html>${items.join('')}</html>`; }
16export function head(...items) { return `<head>${items.join('')}</head>`; }
17export function body(...items) { return `<body">${items.join('')}</body>`; }
18
1// View at https://andreterron-htmlExample.web.val.run?name=Andre
2export default async function(req: Request): Promise<Response> {
3 const query = new URL(req.url).searchParams;
4
1export async function beckerBarley() {
2 const Plot = await import("https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.14/+esm");
3 const d3 = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
1export function myApi(name) {
2 return "hi " + name;
3}
1export default async function(interval) {
2 // Sample phrases and words that are likely to appear in dream descriptions
3 const introPhrases = [
2
3const openai = new OpenAI();
4const functionExpression = await openai.chat.completions.create({
5 "messages": [
6 { "role": "user", "content": "whats the weather in sf" },
8 tools: [
9 {
10 function: {
11 name: "weather",
12 parameters: {
19 },
20 },
21 type: "function",
22 },
23 ],
25});
26
27console.log(functionExpression.choices[0].message.tool_calls);
1export async function token(refresh_token: string) {
2 const tokens: {
3 refresh_token: string;
25}
26
27export function signInList(access_token: string) {
28 return fetch("https://member.aliyundrive.com/v1/activity/sign_in_list?_rx-s=mobile", {
29 method: "POST",
52}
53
54export async function signInReward(access_token: string, signInDay: number /* æœ¬æœˆç¬¬å‡ æ¬¡ç¾åˆ° */) {
55 const res = await fetch("https://member.aliyundrive.com/v1/activity/sign_in_reward?_rx-s=mobile", {
56 method: "POST",
72}
73
74async function getAccessTokenWithValTown(valTownAPIKey?: string): Promise<string> {
75 if (valTownAPIKey) Deno.env.set("valtown", valTownAPIKey);
76 const { blob } = await import("https://esm.town/v/std/blob");
92}
93
94async function checkin(batch = false) {
95 const access_token = await getAccessTokenWithValTown();
96
107}
108
109export default async function() {
110 await checkin(false);
111 await checkin(true);
1import { Kysely, sql } from "npm:kysely";
2
3export async function up(db: Kysely<any>): Promise<void> {
4 await db.schema
5 .createTable("person")
26}
27
28export async function down(db: Kysely<any>): Promise<void> {
29 await db.schema.dropTable("pet").execute();
30 await db.schema.dropTable("person").execute();
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.