9 <title>Hello World</title>
10 <style>
11 @import url('https://fonts.googleapis.com/css2?family=Caveat:wght@700&family=Permanent+Marker&display=swap');
12
13 body {
9 <title>Hello World</title>
10 <style>
11 @import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Pacifico&display=swap');
12
13 body {
9 <title>Hello World</title>
10 <style>
11 @import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Pacifico&display=swap');
12
13 body {
1// This val retrieves the weather in Brooklyn, NY using the MetaWeather API
2
3export default async function main(req: Request): Promise<Response> {
4 const response = await fetch("https://www.metaweather.com/api/location/2459115/");
5 const weatherData = await response.json();
6
1// This val retrieves the weather in Brooklyn, NY using the MetaWeather API
2
3export default async function main(req: Request): Promise<Response> {
4 const response = await fetch("https://www.metaweather.com/api/location/2459115/");
5 const weatherData = await response.json();
6
1// This val fetches weather data from an open API
2// The approach involves using the fetch API provided by Deno
3// to retrieve weather information for a specific location
4
5export default async function main(req: Request): Promise<Response> {
6 const apiUrl = "https://api.open-meteo.com/v1/forecast?latitude=40.6782&longitude=-73.9442&hourly=temperature_2m¤t_weather=true";
7
8 const response = await fetch(apiUrl);
9 const weatherData = await response.json();
10
2 // Helper functions for Blob storage
3 async function getBlob(key: string): Promise<any> {
4 const response = await fetch(`https://api.val.town/v/std/blob-${key}`);
5 if (!response.ok) throw new Error("Error fetching blob data");
6 return response.json();
8
9 async function setBlob(key: string, data: any): Promise<void> {
10 const response = await fetch(`https://api.val.town/v/std/blob-${key}`, {
11 method: "POST",
12 headers: { "Content-Type": "application/json" },
1export async function fetchVal(valId: string) {
2 try {
3 const response = await fetch(`https://api.val.town/v1/vals/${valId}`);
4 if (!response.ok) {
5 console.error(`Error fetching val with ID ${valId}:`, response.statusText);
15export async function evalCode(code: string) {
16 try {
17 const response = await fetch(`https://api.val.town/v1/eval`, {
18 method: 'POST',
19 headers: {
26 const errorText = await response.text();
27 console.error(`Error evaluating code:`, errorText);
28 return { error: `API Error: ${response.status} ${response.statusText}`, rawResponse: errorText };
29 }
30
2import Exa from "npm:exa-js"
3
4const exa = new Exa(Deno.env.get("EXA_API_KEY"));
5
6export const exaSearch = async ({ query, type, useAutoprompt, numResults, text, summary=true, highlights }) => {
12 try {
13 const [priceResponse, historyResponse] = await Promise.all([
14 fetch(`https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=${CONFIG.COIN_GECKO_CURRENCY}`),
15 fetch(
16 `https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=${CONFIG.COIN_GECKO_CURRENCY}&days=${CONFIG.COIN_GECKO_DAYS}&interval=daily`,
17 ),
18 ]);
19
20 if (!priceResponse.ok || !historyResponse.ok) throw new Error("API request failed");
21
22 const priceData = await priceResponse.json();