Spaces:
Runtime error
Runtime error
fix base api
Browse files
frontend/.env.example
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
PUBLIC_WS_ENDPOINT="wss://spaces.huggingface.tech/stabilityai/stable-diffusion/queue/join"
|
2 |
+
PUBLIC_API="/"
|
frontend/src/routes/+page.svelte
CHANGED
@@ -3,16 +3,11 @@
|
|
3 |
import type { ColorsPrompt, ColorsImage } from '$lib/types';
|
4 |
import { randomSeed, extractPalette, uploadImage } from '$lib/utils';
|
5 |
import { isLoading, loadingState } from '$lib/store';
|
6 |
-
import { PUBLIC_WS_ENDPOINT,
|
7 |
import Pallette from '$lib/Palette.svelte';
|
8 |
import ArrowRight from '$lib/ArrowRight.svelte';
|
9 |
import ArrowLeft from '$lib/ArrowLeft.svelte';
|
10 |
|
11 |
-
const apiUrl =
|
12 |
-
PUBLIC_DEV_MODE === 'DEV'
|
13 |
-
? 'http://localhost:7860'
|
14 |
-
: '/embed/huggingface-projects/color-palette-generator-sd';
|
15 |
-
|
16 |
let promptsData: ColorsPrompt[] = [];
|
17 |
let prompt: string;
|
18 |
let promptInputEl: HTMLElement;
|
@@ -26,7 +21,7 @@
|
|
26 |
});
|
27 |
|
28 |
async function fetchData() {
|
29 |
-
const palettes = await fetch(
|
30 |
if (!promptsData || palettes?.length > promptsData?.length) {
|
31 |
promptsData = sortData(palettes);
|
32 |
}
|
@@ -58,7 +53,7 @@
|
|
58 |
}
|
59 |
async function savePaletteDB(colorPrompt: ColorsPrompt) {
|
60 |
try {
|
61 |
-
const newPalettes: ColorsPrompt[] = await fetch(
|
62 |
method: 'POST',
|
63 |
headers: {
|
64 |
'Content-Type': 'application/json'
|
|
|
3 |
import type { ColorsPrompt, ColorsImage } from '$lib/types';
|
4 |
import { randomSeed, extractPalette, uploadImage } from '$lib/utils';
|
5 |
import { isLoading, loadingState } from '$lib/store';
|
6 |
+
import { PUBLIC_WS_ENDPOINT, PUBLIC_API} from '$env/static/public';
|
7 |
import Pallette from '$lib/Palette.svelte';
|
8 |
import ArrowRight from '$lib/ArrowRight.svelte';
|
9 |
import ArrowLeft from '$lib/ArrowLeft.svelte';
|
10 |
|
|
|
|
|
|
|
|
|
|
|
11 |
let promptsData: ColorsPrompt[] = [];
|
12 |
let prompt: string;
|
13 |
let promptInputEl: HTMLElement;
|
|
|
21 |
});
|
22 |
|
23 |
async function fetchData() {
|
24 |
+
const palettes = await fetch(PUBLIC_API + '/data').then((d) => d.json());
|
25 |
if (!promptsData || palettes?.length > promptsData?.length) {
|
26 |
promptsData = sortData(palettes);
|
27 |
}
|
|
|
53 |
}
|
54 |
async function savePaletteDB(colorPrompt: ColorsPrompt) {
|
55 |
try {
|
56 |
+
const newPalettes: ColorsPrompt[] = await fetch(PUBLIC_API + '/new_palette', {
|
57 |
method: 'POST',
|
58 |
headers: {
|
59 |
'Content-Type': 'application/json'
|