1
mirror of https://github.com/comfyanonymous/ComfyUI.git synced 2025-08-03 23:49:57 +08:00

Initial refactoring changes

- Moved to web folder
 - Splitting into individual files
This commit is contained in:
pythongosssss
2023-03-02 20:00:06 +00:00
committed by GitHub
parent 3637e19eff
commit 5e25c77074
9 changed files with 1399 additions and 1117 deletions

36
web/scripts/api.js Normal file
View File

@@ -0,0 +1,36 @@
class ComfyApi {
async getNodeDefs() {
const resp = await fetch("object_info", { cache: "no-store" });
return await resp.json();
}
async queuePrompt(number, { output, workflow }) {
const body = {
client_id: this.clientId,
prompt: output,
extra_data: { extra_pnginfo: { workflow } },
};
if (number === -1) {
body.front = true;
} else if (number != 0) {
body.number = number;
}
const res = await fetch("/prompt", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(body),
});
if (res.status !== 200) {
throw {
response: await res.text(),
};
}
}
}
export const api = new ComfyApi();