1export default async function (req: Request): Promise<Response> {
2 // Check if the request method is POST
3 if (req.method !== 'POST') {
1export default async function(Request: Request): Promise<Response> {
2 return Response.json(Object.fromEntries(Request.headers.entries()));
3}
1export default async function(Request: Request): Promise<Response> {
2 const parsedURL = new URL(Request.url);
3
1export default async function (req: Request): Promise<Response> {
2 // Extract the path from the request URL
3 const path = new URL(req.url).pathname;
1export default function (request: Request): Response {
2 return new Response("Hello world", {
3 headers: { "Content-Type": "text/plain" },
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 return (
7 <div className="container">
28}
29
30function client() {
31 createRoot(document.getElementById("root")).render(<App />);
32}
33if (typeof document !== "undefined") { client(); }
34
35export default async function server(request: Request): Promise<Response> {
36 return new Response(
37 `
3import { createRoot } from "https://esm.sh/react-dom/client";
4
5function App() {
6 const [query, setQuery] = useState("");
7 const [results, setResults] = useState([]);
71}
72
73function client() {
74 createRoot(document.getElementById("root")).render(<App />);
75}
76if (typeof document !== "undefined") { client(); }
77
78export default async function server(request: Request): Promise<Response> {
79 const url = new URL(request.url);
80 if (url.pathname === "/search") {
12const FRED_API_KEY = process.env.FRED_API_KEY;
13
14// Function to fetch rate data from FRED API
15async function getRateData(seriesId: string): Promise<RateData> {
16 const url =
17 `https://api.stlouisfed.org/fred/series/observations?series_id=${seriesId}&api_key=${FRED_API_KEY}&file_type=json&sort_order=desc&limit=2`;
38}
39
40// Function to fetch all rate data
41async function getAllRateData(): Promise<RateData[]> {
42 const seriesIds = ["MORTGAGE30US", "SOFR30DAYAVG"];
43 const promises = seriesIds.map(seriesId => getRateData(seriesId));
45}
46
47// Function to format the email content
48function formatEmailContent(rateDataArray: RateData[]): string {
49 const rateRows = rateDataArray
50 .map(
77}
78
79// Main function to send the email
80export async function sendMortgageRateEmail() {
81 try {
82 const rateDataArray = await getAllRateData();
94}
95
96export default async function(interval: Interval) {
97 try {
98 const mortgageEmail = await sendMortgageRateEmail();
101 return { mortgageEmail: mortgageEmail };
102 } catch (error) {
103 console.error("Error in main function:", error);
104 throw error;
105 }
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [htmlInput, setHtmlInput] = useState("<h1>Hello, World!</h1>"); const [silliness, setSilliness] = useState(0);
8 const [slang, setSlang] = useState(0);
90}
91
92function client() {
93 createRoot(document.getElementById("root")).render(<App />);
94}
98}
99
100async function server(request: Request): Promise<Response> {
101 if (request.method === "POST" && new URL(request.url).pathname === "/api/modify") {
102 const { html, silliness, slang } = await request.json();
1import { versionLogger } from "https://esm.town/v/willthereader/versionLoggger";
2// version one is the one with the javascript scenario
3function App() {
4 let url = "";
5 let chapterTitles = "";
139}
140
141async function fetchThreadmarksFromServer(url, chapterTitles) {
142 const response = await fetch("/api/threadmarks", {
143 method: "POST",
154}
155
156async function getThreadmarkUrls(baseUrl, apiKey) {
157 versionLogger(import.meta.url);
158 const startTime = Date.now();
224}
225
226function parseThreadmarks(data) {
227 // console.log(`[INFO] Starting to parse threadmarks from HTML data. Total data length: ${data.length}`);
228 const threadmarks = [];
241}
242
243function compareThreadmarks(expectedTitles, retrievedThreadmarks) {
244 const expectedTitlesArray = expectedTitles.split("\n").map(title => title.trim()).filter(title => title !== "");
245 const retrievedTitles = retrievedThreadmarks.map(threadmark => threadmark.title);
298}
299
300function client() {
301 // console.log("Initializing client-side application");
302 const app = App();
308}
309
310export default async function server(request) {
311 console.log(`Received ${request.method} request for path: ${new URL(request.url).pathname}`);
312
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.