1import { DOMParser } from "https://deno.land/x/deno_dom/deno-dom-wasm.ts";
2
3export function stripHTML(html: string) {
4 const doc = new DOMParser().parseFromString(html, "text/html");
5 return doc.body.textContent;
5import { renderToString } from "npm:react-dom/server";
6
7function StatusRow({ rows }) {
8 return (
9 <div className="w-full flex flex-col space-y-2">
28}
29
30function StatusSection({ url, rows }) {
31 const sectionRows = rows.filter(row => row[0] === url);
32 const percentUp = Math.round((sectionRows.filter(row => row[1]).length / sectionRows.length) * 100);
44}
45
46export default async function(req: Request): Promise<Response> {
47 const { rows } = await sqlite.execute(
48 "select url, ok, duration, timestamp from uptime order by timestamp desc limit 200",
53
54// Render streaming markdown
55export default async function handler(req: Request): Promise<Response> {
56 const renderMarkdown = (await import("https://esm.town/v/substrate/renderMarkdown")).default;
57 return renderMarkdown(stream);
3import { useState } from "https://esm.sh/hono/jsx/dom";
4
5export default function Counter(props: { initialCount?: number }) {
6 const [count, setCount] = useState(props.initialCount || 0);
7 return (
2import React from 'https://esm.sh/react'
3
4export function ClientOnly({ children, ...delegated }) {
5 const [hasMounted, setHasMounted] = React.useState(false)
6 React.useEffect(() => {
11const getText = async url => (await fetch(url)).text();
12
13function generateSCSS(vars) {
14 let scss = [];
15 for (const v in vars)
22}
23
24async function generateBanner() {
25 const pkg = await getJSON("https://raw.githubusercontent.com/Pinjasaur/cuetip/master/package.json");
26 return [
32}
33
34export default async function(req: Request): Promise<Response> {
35 if (req.method === "OPTIONS") {
36 return new Response(null, {
1import { OpenAI } from "https://esm.town/v/std/openai";
2export default async function(req: Request): Promise<Response> {
3 const openai = new OpenAI();
4 const stream = await openai.chat.completions.create({
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
4const exa = new Exa(exaSecret);
5
6const similarSites = async function(url: string) {
7 const results = await exa.findSimilar(url);
8 if (results.results) {
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.