1const getText = async url => (await fetch(url)).text();
2
3export default async function(req: Request): Promise<Response> {
2// We'll use the built-in Request and Response objects for handling HTTP.
3// The form fields are customized for video information collection.
4// We'll add JSON API endpoints for Framer Fetch integration.
5
6import { blob } from "https://esm.town/v/std/blob";
11 const url = new URL(req.url);
12
13 // API endpoints for Framer Fetch
14 if (url.pathname === "/api/entries") {
15 if (req.method === "GET") {
13
14 try {
15 const weatherResponse = await fetch(weatherApiUrl);
16 if (!weatherResponse.ok) {
17 throw new Error(`Weather API request failed with status: ${weatherResponse.status}`);
33 });
34 } catch (err) {
35 return new Response("Error fetching weather data: " + err.message, {
36 status: 500, // Internal Server Error
37 headers: { "Content-Type": "text/plain" },
138app.notFound((c) => c.render(<NotFoundPage />));
139
140export default app.fetch;
1async function fetchWeather() {
2 const API_KEY = "439d4b804bc8187953eb36d2a8c26a02"; // Example key, replace with your own
3 const LAT = 51.5074; // London latitude
6 `https://api.openweathermap.org/data/2.5/onecall?lat=${LAT}&lon=${LON}&exclude=hourly,daily&units=metric&appid=${API_KEY}`;
7
8 console.log("Fetching weather from URL:", url); // Log the full URL
9
10 try {
11 const response = await fetch(url);
12
13 if (!response.ok) {
17 return await response.json();
18 } catch (error) {
19 console.error("Error fetching weather data:", error);
20 return null;
21 }
62
63export default async function main(req) {
64 const weather = await fetchWeather();
65 const url = `http://api.openweathermap.org/data/2.5/forecast/daily?q=London&appid=439d4b804bc8187953eb36d2a8c26a02`;
66 const html = generateHTML(weather, url);
122app.notFound((c) => c.render(<NotFoundPage />));
123
124export default app.fetch;
1## Detect New Website Contents
2
3This val fetches a given publicly-accessible URL and detects whether its contents have changed. If they have, it sends an email to notify about the change.
4
5Changes are detected by computing a quick hash of the website's contents, storing the hash, and comparing against the previously stored hash on each request. Trivial changes to the website's contents will count as a change, which may not be desired for some use cases.
8
9export const detectNewWebsiteContents = async () => {
10 // Fetch contents
11 let contents;
12 try {
13 const res = await fetch(URL, { redirect: "follow" });
14 if (res.status !== 200) {
15 console.log(`bad status code: ${res.status}`);
17 contents = await res.text();
18 } catch (e) {
19 console.log(`couldn't fetch: ${e}`);
20 }
21
1import { email } from "https://esm.town/v/std/email";
2import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
3import { load } from "npm:cheerio";
4
5export default async (interval: Interval) => {
6 const html = await fetchText(Deno.env.get("rubbish_url"));
7 const $ = load(html);
8 const containers = $(".bin-collection-container");
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 })));