1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
6
23
24 try {
25 const response = await fetch("/", {
26 method: "POST",
27 body: JSON.stringify({ prompt, currentCode: code }),
1import { email } from "https://esm.town/v/std/email?v=9";
2
3// Fetches a random joke:
4async function fetchRandomJoke() {
5 const response = await fetch(
6 "https://official-joke-api.appspot.com/random_joke",
7 );
9}
10
11const randomJoke = await fetchRandomJoke();
12const setup = randomJoke.setup;
13const punchline = randomJoke.punchline;
64
65 console.log(">>>> Data", data)
66 const response = await fetch(pipeline_url, {
67 method: "POST",
68 headers: {
302 }
303
304 const response = await fetch('/pageshot', {
305 method: 'POST',
306 headers: {
559app.post("/pageshot", pageshotHandler);
560
561export default (typeof Deno !== "undefined" && Deno.env.get("valtown")) ? app.fetch : app;
562
34
35 try {
36 const response = await fetch("/translate", {
37 method: "POST",
38 headers: {
214
215 // 使用开放的翻译API作为备选方案
216 const translationResponse = await fetch(
217 `https://translate.googleapis.com/translate_a/single?client=gtx&sl=${source_lang === 'auto' ? 'auto' : source_lang}&tl=${target_lang}&dt=t&q=${encodeURIComponent(text)}`,
218 {
62
63 useEffect(() => {
64 const fetchYCCompanies = async () => {
65 const storedCompanies = localStorage.getItem("ycCompanies");
66 if (storedCompanies) {
69 setDebugInfo(prevInfo => prevInfo + `\nLoaded ${companies.length} companies from localStorage`);
70 } else {
71 const response = await fetch("/companies.json");
72 const companies = await response.json();
73 setYcCompanies(companies);
74 localStorage.setItem("ycCompanies", JSON.stringify(companies));
75 setDebugInfo(prevInfo =>
76 prevInfo + `\nFetched ${companies.length} companies from server and stored in localStorage`
77 );
78 }
79 };
80 fetchYCCompanies();
81 }, []);
82
226
227export default async function server(request: Request): Promise<Response> {
228 const companies = await fetch("https://stevekrouse-yc_database.web.val.run").then(res => res.json());
229 const url = new URL(request.url);
230 if (url.pathname === "/companies.json") {
7const BLOB_KEY = "yc-companies";
8// To reset the blob cache, uncomment the following line:
9// await blob.set(BLOB_KEY + ".csv", await (await fetch(GOOGLE_SHEET_CSV_URL)).blob());
10
11interface Row {
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
6
4let location = "munchen";
5let lang = "en";
6const weather = await fetch(
7 `https://wttr.in/${location}?lang=${lang}&format=j1`,
8).then(r => r.json());
9 const variable: string = await blob.getJSON(blobKey) ?? "";
10
11 const response = await fetch(scrapeURL);
12 const body = await response.text();
13 const $ = cheerio.load(body);