Download src/js/api.js from bayan10/bayan-api: direct link, hf CLI and curl.
- Browser
- Download file 1.57 kB
-
https://huggingface.co/spaces/bayan10/bayan-api/resolve/main/src/js/api.js
- Command line
-
hf download hf://spaces/bayan10/bayan-api/src/js/api.js
-
curl -L -o api.js https://huggingface.co/spaces/bayan10/bayan-api/resolve/main/src/js/api.js
1.57 kB
| // src/js/api.js | |
| export async function analyzeText(text) { | |
| const response = await fetch('/api/analyze', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ text }) | |
| }); | |
| if (!response.ok) throw new Error('Analyze API error'); | |
| return await response.json(); | |
| } | |
| export async function summarizeText(text, length = 2, full = true) { | |
| const response = await fetch('/api/summarize', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ text, length, full_text: full }) | |
| }); | |
| if (!response.ok) throw new Error('Summarize API error'); | |
| return await response.json(); | |
| } | |
| export async function getSpelling(text) { | |
| const response = await fetch('/api/spelling', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ text }) | |
| }); | |
| if (!response.ok) throw new Error('Spelling API error'); | |
| return await response.json(); | |
| } | |
| export async function getGrammar(text) { | |
| const response = await fetch('/api/grammar', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ text }) | |
| }); | |
| if (!response.ok) throw new Error('Grammar API error'); | |
| return await response.json(); | |
| } | |
| export async function getPunctuation(text) { | |
| const response = await fetch('/api/punctuation', { | |
| method: 'POST', | |
| headers: { 'Content-Type': 'application/json' }, | |
| body: JSON.stringify({ text }) | |
| }); | |
| if (!response.ok) throw new Error('Punctuation API error'); | |
| return await response.json(); | |
| } | |