9
10// Generic loader that forwards on requests for that page's JSON data
11function loader({ request }) {
12 return fetch(request, {
13 headers: {
18
19// Generic action that forwards on non-get Requests
20function action({ request }) {
21 if (request.method === "GET") { throw Error("GET not expected here - something is wrong."); }
22 return fetch(request);
23}
24
25function makeClientSide(routes) {
26 return routes.map(route => {
27 return {
37];
38
39function Success() {
40 return (
41 <div className="max-w-md text-lg mx-auto p-6">
2import { useEffect, useState } from "https://esm.sh/react@18.2.0";
3
4async function getCurrentPosition(opts): Promise<GeolocationPosition> {
5 return new Promise((resolve, reject) => {
6 if (!navigator?.geolocation) {
12}
13
14async function reverseGeocodeNominat(lat, lng) {
15 const url = `https://nominatim.openstreetmap.org/reverse?format=json&lat=${lat}&lon=${lng}&zoom=13`;
16 const response = await fetch(url);
19}
20
21export default function Home() {
22 const [locationName, setLocationName] = useState("");
23 useEffect(() => {
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 console.log(setup, punchline);
13
14// Generic loader that forwards on requests for that page's JSON data
15function loader({ request }) {
16 return fetch(request, {
17 headers: {
22
23// Generic action that forwards on non-get Requests
24function action({ request }) {
25 if (request.method === "GET") { throw Error("GET not expected here - something is wrong."); }
26 return fetch(request);
2import { action as submit_action } from "https://esm.town/v/stevekrouse/dateme_form_react";
3
4async function server(req: Request) {
5 const url = new URL(req.url);
6 if (url.pathname === "/browse") {
13}
14
15function client(req: Request) {
16 return new Response(
17 `<html>
32}
33
34export default function(req: Request) {
35 if (
36 req.headers.get("Content-Type") === "application/json"
5import { render } from "npm:jsonresume-theme-microdata";
6
7export default async function resumeHandler(req: Request): Promise<Response> {
8 if (req.method === "GET") {
9 try {
1export default async function(req: Request): Promise<Response> {
2 const response = await fetch("http://worldtimeapi.org/api/timezone/America/New_York")
3 const timeData = await response.json()
5import { zodToJsonSchema } from "npm:zod-to-json-schema";
6
7export default async function(interval: Interval) {
8 let html = await loadPageContent("https://news.ycombinator.com/", { textContent: false });
9
28 // we create a OpenAI Tool that takes our schema as argument
29 const extractContentTool: any = {
30 type: "function",
31 function: {
32 name: "extract_content",
33 description: "Extracts the content from the given webpage(s)",
57
58 // we retrieve the serialized arguments generated by OpenAI
59 const result = completion.choices[0].message.tool_calls![0].function.arguments;
60
61 console.log(result);
1import { ImageMagick, initializeImageMagick, MagickGeometry } from "https://deno.land/x/imagemagick_deno@0.0.14/mod.ts";
2
3export async function modifyImage(
4 input: Uint8Array | "logo:",
5) {
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": "*",