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.
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
2import * as cheerio from "npm:cheerio";
3
4export async function extractAllContent(request: Request) {
5 try {
6 const body = await request.json();
2import { email } from "https://esm.town/v/std/email";
3
4export async function testEmail2(e: {
5 from: string;
6 to: string[];
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({
5const confidenceThreshold = 0.8;
6
7function randomlyPickFeature(featuresAboveConfidenceThreshold) {
8 return featuresAboveConfidenceThreshold[Math.floor(Math.random() * featuresAboveConfidenceThreshold.length)];
9}
10
11function getFeatureLink(feature) {
12 const { index } = feature;
13 return `https://thesephist--prism-start-app.modal.run/f/${modelName}/${index}?layout=2`;
14}
15
16export default async function(interval: Interval) {
17 const response = await fetch(dictionaryUrl);
18 const { features } = await response.json();
218if (jwk.y) console.assert(jwk.y === resolvedJwk.y);
219
220async function resolveDid(did: string) {
221 const data = await ky.get(`https://dev.uniresolver.io/1.0/identifiers/${did}`).json();
222 return data.verificationMethod.at(0).publicKeyJwk;
17};
18
19export function jwkToMultibase(jwk: JWK) {
20 if (jwk.kty === "OKP") {
21 const bytes = base64url.baseDecode(jwk.x);
32}
33
34export function jwkToDidKey(jwk: JWK) {
35 const keyMultibase = jwkToMultibase(jwk);
36 return `did:key:${keyMultibase}`;
5import { secp256k1 } from "npm:@noble/curves/secp256k1";
6
7export function decompressPoint(bytes: Uint8Array, curve: string) {
8 if (curve === "P-256") {
9 const point = p256.ProjectivePoint.fromHex(bytes);
17}
18
19function pointToBytes<T>(point: ProjPointType<T>, Fp: IField<T>) {
20 const x = Fp.toBytes(point.x);
21 const y = Fp.toBytes(point.y);
24
25// @see: https://stackoverflow.com/questions/17171542/algorithm-for-elliptic-curve-point-compression
26export function compressPoint({ x, y }: { x: Uint8Array; y: Uint8Array }) {
27 const compressed = new Uint8Array(x.length + 1);
28 compressed[0] = 2 + (y.at(-1) & 1);
5
6// borrowed from: https://github.com/benvinegar/counterscale/blob/main/app/analytics/query.ts#L24
7function accumulateCountsFromRowResult(
8 counts,
9 row: {
22}
23
24export default async function(interval: Interval) {
25 // you need to declare these two environment variables:
26
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",