28 }, []);
29
30 async function fetchLocationSuggestions(query) {
31 if (query.length < 2) {
32 setLocationSuggestions([]);
35
36 try {
37 const response = await fetch(
38 `https://geocoding-api.open-meteo.com/v1/search?name=${encodeURIComponent(query)}&count=5&language=en&format=json`
39 );
54 }
55 } catch (err) {
56 console.error('Failed to fetch location suggestions', err);
57 setLocationSuggestions([]);
58 setShowSuggestions(false);
63 const value = e.target.value;
64 setLocationInput(value);
65 fetchLocationSuggestions(value);
66 };
67
70 setLocation(selectedLocation);
71 setShowSuggestions(false);
72 await fetchWeatherData(selectedLocation);
73 }
74
75 async function fetchWeatherData(coords) {
76 try {
77 const response = await fetch(
78 `https://api.open-meteo.com/v1/forecast?latitude=${coords.latitude}&longitude=${coords.longitude}¤t_weather=true&hourly=temperature_2m,precipitation_probability,weathercode&daily=weathercode,temperature_2m_max,temperature_2m_min&timezone=auto`
79 );
82 setError(null);
83 } catch (err) {
84 setError('Failed to fetch weather data');
85 }
86 }
94
95 useEffect(() => {
96 fetchWeatherData(location);
97 }, []);
98
31 for (const url of possibleUrls) {
32 try {
33 sourceResp = await fetch(url);
34 if (sourceResp.status === 200) {
35 return sourceResp;
1import app from "https://wilt-npmproxy.web.val.run/cachebust4/raw.githubusercontent.com/wilt00/bskye/refs/heads/type-imports/src/index.ts";
2
3export default app.fetch;
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
182
183 try {
184 const response = await fetch("/", {
185 method: "POST",
186 body: JSON.stringify({
14 start = performance.now();
15 try {
16 const res = await fetch(url);
17 end = performance.now();
18 status = res.status;
25 } catch (e) {
26 end = performance.now();
27 reason = `couldn't fetch: ${e}`;
28 ok = false;
29 console.log(`Website down (${url}): ${reason} (${end - start}ms)`);
183
184 try {
185 const response = await fetch("/", {
186 method: "POST",
187 body: JSON.stringify({
8 }
9
10 const response = await fetch(`https://ntfy.sh/${ntfyChannel}`, {
11 method: "POST",
12 body: `How much do you weigh?`,
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));
1/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
2
3import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
4import { iframeHandler } from "https://esm.town/v/nbbaier/iframeHandler";
5import { resetStyle } from "https://esm.town/v/nbbaier/resetStyle";
16import { verifyToken } from "https://esm.town/v/pomdtr/verifyToken";
17import { ResultSet, sqlite } from "https://esm.town/v/std/sqlite";
18import { reloadOnSaveFetchMiddleware } from "https://esm.town/v/stevekrouse/reloadOnSave";
19import { Hono } from "npm:hono";
20import type { FC } from "npm:hono/jsx";
175});
176
177export const handler = app.fetch;
178export default iframeHandler(modifyFetchHandler(passwordAuth(handler, { verifyPassword: verifyToken })));