Spaces:
Runtime error
Runtime error
Download static/components/api.js from Scalino84/FluxInator: direct link, hf CLI and curl.
- Browser
- Download file 1.91 kB
-
https://huggingface.co/spaces/Scalino84/FluxInator/resolve/main/static/components/api.js
- Command line
-
hf download hf://spaces/Scalino84/FluxInator/static/components/api.js
-
curl -L -o api.js https://huggingface.co/spaces/Scalino84/FluxInator/resolve/main/static/components/api.js
1.91 kB
| // static/components/api.js | |
| export const API = { | |
| albums: { | |
| list: '/albums', // Vermutung basierend auf AlbumManager.js | |
| create: '/create_album', | |
| delete: (id) => `/delete_album/${id}`, | |
| update: (id) => `/update_album/${id}`, | |
| }, | |
| categories: { | |
| list: '/categories', // Vermutung basierend auf CategoryManager.js | |
| create: '/create_category', | |
| delete: (id) => `/delete_category/${id}`, | |
| update: (id) => `/update_category/${id}`, | |
| merge: '/categories/merge' | |
| }, | |
| statistics: { | |
| images: '/backend/stats', | |
| storage: '/backend/stats' | |
| } | |
| }; | |
| export const APIHandler = { | |
| get: async (url) => { | |
| const response = await fetch(url); | |
| if (!response.ok) { | |
| throw new Error('Network response was not ok'); | |
| } | |
| return response.json(); | |
| }, | |
| post: async (url, data) => { | |
| const response = await fetch(url, { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify(data) | |
| }); | |
| if (!response.ok) { | |
| throw new Error('Network response was not ok'); | |
| } | |
| return response.json(); | |
| }, | |
| put: async (url, data) => { | |
| //PUT hinzufügen | |
| const response = await fetch(url, { | |
| method: 'PUT', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify(data) | |
| }); | |
| if (!response.ok) { | |
| throw new Error('Network response was not ok'); | |
| } | |
| return response.json(); | |
| }, | |
| delete: async (url) => { | |
| const response = await fetch(url, { | |
| method: 'DELETE' | |
| }); | |
| if (!response.ok) { | |
| throw new Error('Network response was not ok'); | |
| } | |
| return response.json(); | |
| } | |
| }; | |