15
16// Takoma Park, MD weather forecast
17// https://weather-gov.github.io/api/gridpoints
18const NOAA_URL_TKPK = "https://api.weather.gov/gridpoints/LWX/97,75/forecast/hourly";
19
20interface Period {
52}
53
54// Sleep a random amount of seconds (to respect NOAA's API).
55async function sleepRand(seconds: number) {
56 const s = Math.random() * seconds * 1000;
3export default async function(req: Request): Promise<Response> {
4 const { string, stringColor } = await imageToAscii(
5 "https://webcams.nyctmc.org/api/cameras/9fa5b0dd-e955-449e-97e1-9c53ad9c23a8/image",
6 150,
7 );
1Migrated from folder: Archive/geolocation_api_demo
12
13
14NYC has a bunch of traffic cameras and makes them available through static images [like this one](https://webcams.nyctmc.org/api/cameras/858ef4e8-5058-4db2-96e2-70f71b65aa24/image). If you refresh the page you'll see the image update every 2 seconds or so. I thought it might be fun to make these cameras viewable as an ASCII art video feed. I made a [small library](https://www.val.town/v/maxm/imageToAscii) that takes most of its logic from [this repo](https://github.com/victorqribeiro/imgToAscii). You can see a basic example of how to convert [any image to ASCII here](https://www.val.town/v/maxm/asciiImageExample).
15
16I pull in [NYC GeoJSON from here](https://observablehq.com/@miaozhang/maps) and then hook up a Server-Sent Events endpoint to stream the ASCII updates to the browser. (Polling would work just as well, I've just been on a bit of a SSE kick lately.)
2
3// use my private proxy
4setEnv("VALTOWN_API_URL", "https://pomdtr-tursoproxy.web.val.run");
5
6// need to be dynamic
29 app.all("*", async (c) => {
30 const { path } = c.req;
31 return await fetch(`https://api.val.town${path}`, {
32 method: c.req.method,
33 headers: c.req.raw.headers,
1# Use GPT to generate vals on your account!
2
3Describe the val that you need, call this function, and you'll get a new val on your workspace generated by OpenAI's API!
4
5First, ensure you have a [Val Town API Token](https://www.val.town/settings/api), then call `@andreterron.createGeneratedVal({...})` like this [example](https://www.val.town/v/andreterron.untitled_tomatoKiwi):
6
7```javascript
1import { saveToTana } from "https://esm.town/v/impedivity/saveToTana";
2import { APIPlainNode } from "https://esm.town/v/nbbaier/tanaTypes";
3import { Hono } from "npm:hono";
4
5const token = Deno.env.get("tanaInputAPI");
6
7export const honoTanaEndpoint = async (req: Request) => {
10 let { text, url } = c.req.query();
11 console.log(c.req);
12 const payload: APIPlainNode = {
13 name: text,
14 children: [
1import { saveToTana } from "https://esm.town/v/impedivity/saveToTana";
2import { APIPlainNode } from "https://esm.town/v/nbbaier/tanaTypes";
3import { Hono } from "npm:hono";
4
5const token = Deno.env.get("tanaInputAPI");
6console.log(token);
7console.log(Request);
16 let { text, url } = c.req.query();
17 console.log(c.req);
18 const payload: APIPlainNode = {
19 name: text,
20 children: [
15
16// use my private proxy
17setEnv("VALTOWN_API_URL", "<proxy-url>");
18
19// wire sqlite explorer to a turso db !