21 const text = formData.get('text');
22
23 const response = await fetch(window.location.href, {
24 method: 'POST',
25 body: formData
21 const source_sentence = document.getElementById('source_sentence').value;
22 const sentences = document.getElementById('sentences').value.split(',').map(sentence => sentence.trim());
23 const response = await fetch('/extract-features', {
24 method: 'POST',
25 headers: { 'Content-Type': 'application/json' },
21 const question = document.getElementById('question').value;
22 const context = document.getElementById('context').value;
23 const response = await fetch('/qa', {
24 method: 'POST',
25 headers: { 'Content-Type': 'application/json' },
18 event.preventDefault();
19 const text = document.getElementById('text').value;
20 const response = await fetch('/summarize', {
21 method: 'POST',
22 headers: { 'Content-Type': 'application/json' },
18 event.preventDefault();
19 const text = document.getElementById('text').value;
20 const response = await fetch('/generate', {
21 method: 'POST',
22 headers: { 'Content-Type': 'application/json' },
18 event.preventDefault();
19 const text = document.getElementById('text').value;
20 const response = await fetch('/classify', {
21 method: 'POST',
22 headers: { 'Content-Type': 'application/json' },
93 async callHuggingFaceAPI(payload, options) {
94 try {
95 const response = await fetch(`${HUGGING_FACE_API_URL}/${this.model}`, {
96 method: "POST",
97 headers: {
50});
51
52export default app.fetch;
53
1async function fetchUser(token: string): Promise<{ id: string }> {
2 const resp = await fetch("https://api.val.town/v1/me", {
3 headers: {
4 Authorization: `Bearer ${token}`,
7
8 if (resp.status !== 200) {
9 throw new Error("Could not fetch user");
10 }
11
15export async function verifyToken(token: string) {
16 try {
17 const [currentUser, requestUser] = await Promise.all([fetchUser(Deno.env.get("valtown")), fetchUser(token)]);
18 return currentUser.id == requestUser.id;
19 } catch (_) {
110 return comments;
111 } catch (error) {
112 console.error(`Error fetching comments for task ${taskId}:`, error);
113 return [];
114 }
135async function downloadImage(url) {
136 try {
137 const response = await fetch(url, {
138 headers: {
139 Authorization: `Bearer ${TODOIST_API_KEY}`,
322
323 try {
324 const response = await fetch(url, {
325 method: "POST",
326 headers: headers,
349
350 try {
351 const response = await fetch(url, {
352 method: "POST",
353 headers: headers,
373
374 try {
375 const response = await fetch(url, {
376 method: "POST",
377 headers: headers,
403
404 try {
405 const response = await fetch(url, { method: "GET", headers: headers });
406 if (!response.ok) {
407 throw new Error(`HTTP error! status: ${response.status}`);