29 e.preventDefault();
30 setLoading(true);
31 const cron = await fetch("/compile", {
32 method: "POST",
33 body: new FormData(e.target as HTMLFormElement),
5
6const app = new Hono();
7export default app.fetch;
8app.get("/", (c) =>
9 c.html(
89 button.disabled = true;
90 button.innerText = "Loading..";
91 const cron = await fetch("/compile", { method: "POST", body: new FormData(form) }).then((r) => r.text());
92 button.disabled = false;
93 button.innerText = "Compile";
189 const formData = new FormData();
190 formData.append("audio", blob, "recording.wav");
191 const response = await fetch("/transcribe", { method: "POST", body: formData });
192 if (response.ok) {
193 const result = await response.text();
229 const language2Value = document.getElementById("language2").value;
230
231 const response = await fetch("/translate", {
232 method: "POST",
233 headers: { "Content-Type": "application/json" },
271
272 if (text && voice) {
273 const response = await fetch('/generate-speech', {
274 method: 'POST',
275 headers: { 'Content-Type': 'application/json' },
401
402
403export default app.fetch;
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(location: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${location}?format=j1`);
5}
6
1import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON";
2
3export async function getWeather(city: string): Promise<WeatherResponse> {
4 return fetchJSON(`https://wttr.in/${city}?format=j1`);
5}
6
55 "embed",
56 "document",
57 ].includes(req.headers.get("sec-fetch-dest"))
58 )
59 return new Response(
16 const pathname = `/api/latest/user/${user}/workspace/${workspace}/query`;
17
18 const resp = await fetch(`${origin}${pathname}?sql=${encodeURIComponent(sql)}`, {
19 headers: {
20 Authorization: `Bearer ${Deno.env.get("PIPES_TOKEN")}`,
12
13 try {
14 const response = await fetch(url);
15 const data = await response.json();
16 return data;
111});
112
113export default app.fetch;
10}
11
12export async function fetchEnv() {
13 const { data: res, error } = await fetchValTown("/v1/eval", {
14 method: "POST",
15 body: JSON.stringify({
28}
29
30export async function fetchValTown<T = any>(
31 path: string,
32 options?: RequestInit & {
45
46 while (true) {
47 const resp = await fetch(url, {
48 headers,
49 });
68 }
69
70 const resp = await fetch(`${apiURL}${path}`, {
71 ...options,
72 headers,
96 : {};
97
98const { data: me } = await fetchValTown("/v1/me");
99const valDir = path.join(Deno.cwd(), me.username);
100if (!existsSync(valDir)) {
112 confirm(`A new val ${file} was found. Do you want to create it on remote?`)
113 ) {
114 const { data } = await fetchValTown("/v1/vals", {
115 method: "POST",
116 headers: {
139
140 if (confirm(`File ${file} has changed. Do you want to update it on remote?`)) {
141 await fetchValTown(`/v1/vals/${meta.id}`, {
142 method: "PATCH",
143 headers: {
160 confirm(`File ${name} was deleted. Do you want to delete it on remote?`)
161 ) {
162 await fetchValTown(`/v1/vals/${meta.id}`, { method: "DELETE" });
163 delete lock[name];
164 }
170
171// remote -> local
172const { data: vals } = await fetchValTown(`/v1/users/${me.id}/vals`, {
173 paginate: true,
174});
246}
247
248const remoteEnv = await fetchEnv();
249const localEnv = existsSync("val-town.env")
250 ? dotenv.parse(Deno.readTextFileSync("val-town.env"))