1/**
2* This program creates an HTTP server that fetches various data from NASA APIs
3* and returns a JSON response with a collection of interesting information about today.
4* It uses multiple NASA APIs to gather diverse space-related data, including real-time imagery
5* and additional interesting data points.
6*/
8import { DOMParser } from "https://esm.sh/linkedom";
910const NASA_API_KEY = 'vYg1cCNLVbcgNemMWuLEjoJsGOGbBXZjZjmwVwuV';
1112async function fetchNASAData() {
1415// Fetch Astronomy Picture of the Day
16const apodResponse = await fetch(`https://api.nasa.gov/planetary/apod?api_key=${NASA_API_KEY}`);
17const apodData = await apodResponse.json();
1819// Fetch latest EPIC image metadata
20const epicResponse = await fetch(`https://api.nasa.gov/EPIC/api/natural?api_key=${NASA_API_KEY}`);
21const epicData = await epicResponse.json();
22const latestEpicImage = epicData[0];
2324// Fetch Near Earth Objects for today
25const neowsResponse = await fetch(`https://api.nasa.gov/neo/rest/v1/feed?start_date=${today}&end_date=${today}&api_key=${NASA_API_KEY}`);
26const neowsData = await neowsResponse.json();
2728// Fetch Mars Weather data (note: this data is not always up-to-date)
29const marsWeatherResponse = await fetch(`https://api.nasa.gov/insight_weather/?api_key=${NASA_API_KEY}&feedtype=json&ver=1.0`);
30const marsWeatherData = await marsWeatherResponse.json();
3132// Fetch Earth Observatory Natural Event Tracker (EONET) data
33const eonetResponse = await fetch(`https://eonet.gsfc.nasa.gov/api/v3/events`);
34const eonetData = await eonetResponse.json();
3536// Fetch ISS Current Location
37const issResponse = await fetch('http://api.open-notify.org/iss-now.json');
38const issData = await issResponse.json();
3940// Fetch NASA Image and Video Library data
41const nasaLibraryResponse = await fetch(`https://images-api.nasa.gov/search?q=space&media_type=image`);
42const nasaLibraryData = await nasaLibraryResponse.json();
43
451. Click `Fork`
62. Change `location` (Line 4) to describe your location. It accepts fairly flexible English descriptions which it turns into locations via [nominatim's geocoder API](https://www.val.town/v/stevekrouse/nominatimSearch).
73. Click `Run`
8
sqliteExplorerAppREADME.md1 match
13## Authentication
1415Login to your SQLite Explorer with [password authentication](https://www.val.town/v/pomdtr/password_auth) with your [Val Town API Token](https://www.val.town/settings/api) as the password.
1617## Todos / Plans
sqliteExplorerAppmain.tsx2 matches
27<head>
28<title>SQLite Explorer</title>
29<link rel="preconnect" href="https://fonts.googleapis.com" />
3031<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
32<link
33href="https://fonts.googleapis.com/css2?family=Fira+Code:wght@300..700&family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
34rel="stylesheet"
35/>
54You can attach files to your emails by using the `attachments` field.
55Attachments need to be [Base64](https://en.wikipedia.org/wiki/Base64) encoded,
56which is that the [btoa](https://developer.mozilla.org/en-US/docs/Web/API/btoa)
57method is doing in this example:
58
1import { API_URL } from "https://esm.town/v/std/API_URL";
2import { parseSendGridEmail } from "https://esm.town/v/stevekrouse/parseSendGridEmail?v=8";
3import { parseSendGridEmails } from "https://esm.town/v/stevekrouse/parseSendGridEmails?v=10";
69}) => {
70let result = await fetch(
71`${API_URL}/v1/email`,
72{
73method: "POST",
reluctantCoffeeGayalmain.tsx9 matches
49const fetchAnswersAndRankings = async () => {
50if (user) {
51const response = await fetch("/api/answers");
52const data = await response.json();
53setAnswers(data.answers);
59const saveAnswer = useCallback(async (newAnswer: Answer, losingAnswer: string) => {
60if (user) {
61await fetch("/api/answer", {
62method: "POST",
63headers: { "Content-Type": "application/json" },
70const clearAnswers = useCallback(async () => {
71if (user) {
72await fetch("/api/clear-answers", { method: "POST" });
73setAnswers([]);
74setRankings([]);
242const handleLogin = useCallback(async (e: React.FormEvent) => {
243e.preventDefault();
244const response = await fetch("/api/login", {
245method: "POST",
246headers: { "Content-Type": "application/json" },
314315const url = new URL(request.url);
316if (url.pathname === "/api/login") {
317const { username } = await request.json();
318await sqlite.execute(`INSERT OR IGNORE INTO ${KEY}_users (username) VALUES (?)`, [username]);
321}
322323if (url.pathname === "/api/answer") {
324const { questionId, answer, losingAnswer } = await request.json();
325const userId = 1; // In a real app, you'd get this from the session
333}
334335if (url.pathname === "/api/answers") {
336const userId = 1; // In a real app, you'd get this from the session
337const answers = (await sqlite.execute(`SELECT * FROM ${KEY}_answers WHERE user_id = ?`, [userId])).rows;
340}
341342if (url.pathname === "/api/clear-answers") {
343const userId = 1; // In a real app, you'd get this from the session
344await sqlite.execute(`DELETE FROM ${KEY}_answers WHERE user_id = ?`, [userId]);
411412const css = `
413@import url('https://fonts.googleapis.com/css2?family=Pacifico&family=Roboto:wght@300;400;500&display=swap');
414415:root {
fancyPlumSquirrelmain.tsx2 matches
1/**
2* This val creates an elegant and professional web app for managing panel members for the State Street discussion.
3* It uses React for the UI, SQLite for storing panel member information, and the Fetch API to communicate with the server.
4* The design is clean and sophisticated, with a muted color palette and subtle animations.
5*/
182183const css = `
184@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;700&family=Roboto:wght@300;400;700&display=swap');
185186:root {
masterPancakeCheckermain.tsx2 matches
6import { email } from "https://esm.town/v/std/email";
78const THEATER_API = "https://drafthouse.com/s/mother/v2/schedule/collection/austin/master-pancake";
9const STORAGE_KEY = "alamo_showings";
1011async function fetchShowings() {
12const response = await fetch(THEATER_API);
13return await response.json();
14}
AlgoliaRecordSender2main.tsx4 matches
1// Importing environment variables
2const ALGOLIA_APP_ID = Deno.env.get("ALGOLIA_APP_ID");
3const ALGOLIA_WRITE_API_KEY = Deno.env.get("ALGOLIA_WRITE_API_KEY");
4const ALGOLIA_INDEX_NAME = "Test_index";
5227"chapterTitle": "A Side Ws",
228"chapterNumber": 1,
229"content": "If Hitler were president she'd have to obey him. Someone forced her to put people in the Birdcage when she didn't want to, but other times left her orders vague and unclear? Gave her loopholes? Who had legal authority over Dragon? \"You don't have to ask stupid questions,\" Forecast suggested. \"You're smart enough to figure out what was going on. Why Dragon was afraid of being used. Why Taylor and Veda were working with Armsmaster to set her free.\" She paused, a hiss escaping her breath from wherever she was. \"No one deserves to be a slave, to be used for what they are with no care for who they are.\" The PRT. No, the Triumvirate. \"You're saying Alexandria knew.\" Forecast didn't answer at first. She waited a second and then another. \"You don't need me to answer that,\" she stated confidently. \"They were trying to free her?\" Halberd asked. \"Break the restrictions?\" \"Yes. The only problem was the Dragonslayers.",
230"startIndex": 378,
231"endIndex": 398,
491"chapterTitle": "A Side Ws",
492"chapterNumber": 1,
493"content": "Chambers downed his drink rapidly. \"Well. Good luck with that, but I'll warn you now that no one likes watching criminals go free, even if they have a sad story.\" \"I do not need to find a way to let them out,\" Veda declared. \"I already possess one.\" \"You can't do that,\" Banks snapped. \"You don't have the—\" \"Newtype is presently in the process of releasing Jillian Monroe, Thomas Heyworth, Cecil Nunyez, and Veronica Lyod from confinement. We will be returning them home this afternoon.\" Eyes widened and more shouts started to fill the room. Kamil settled into his seat, thinking. \"I trust that the PRT will respect that all four of these individuals are definitively innocent of the crimes that put them in the Birdcage.\" That was a warning. \"How?\" Seneca asked, her voice making it through all the others. \"How are you getting them out?\" \"Through the Birdcage's own inbuilt systems… You are unaware of this?\" Kamil raised his brow again. \"You're saying that there is a way out of the Birdcage? It's part of the prison itself?\" \"It is. I have access to several detailed requests Dragon made to the PRT.",
494"startIndex": 840,
495"endIndex": 860,
662const headers = {
663"Content-Type": "application/json",
664"X-Algolia-API-Key": ALGOLIA_WRITE_API_KEY,
665"X-Algolia-Application-Id": ALGOLIA_APP_ID,
666};