Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
8d0a1423
Commit
8d0a1423
authored
Mar 24, 2023
by
pythongosssss
Browse files
adds simple access to server from custom nodes
parent
dd095efc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
server.py
server.py
+2
-0
web/scripts/api.js
web/scripts/api.js
+12
-1
No files found.
server.py
View file @
8d0a1423
...
@@ -29,6 +29,8 @@ async def cache_control(request: web.Request, handler):
...
@@ -29,6 +29,8 @@ async def cache_control(request: web.Request, handler):
class
PromptServer
():
class
PromptServer
():
def
__init__
(
self
,
loop
):
def
__init__
(
self
,
loop
):
PromptServer
.
instance
=
self
mimetypes
.
init
();
mimetypes
.
init
();
mimetypes
.
types_map
[
'.js'
]
=
'application/javascript; charset=utf-8'
mimetypes
.
types_map
[
'.js'
]
=
'application/javascript; charset=utf-8'
self
.
prompt_queue
=
None
self
.
prompt_queue
=
None
...
...
web/scripts/api.js
View file @
8d0a1423
class
ComfyApi
extends
EventTarget
{
class
ComfyApi
extends
EventTarget
{
#
registered
=
new
Set
();
constructor
()
{
constructor
()
{
super
();
super
();
}
}
addEventListener
(
type
,
callback
,
options
)
{
super
.
addEventListener
(
type
,
callback
,
options
);
this
.
#
registered
.
add
(
type
);
}
/**
/**
* Poll status for colab and other things that don't support websockets.
* Poll status for colab and other things that don't support websockets.
*/
*/
...
@@ -82,8 +89,12 @@ class ComfyApi extends EventTarget {
...
@@ -82,8 +89,12 @@ class ComfyApi extends EventTarget {
this
.
dispatchEvent
(
new
CustomEvent
(
"
executed
"
,
{
detail
:
msg
.
data
}));
this
.
dispatchEvent
(
new
CustomEvent
(
"
executed
"
,
{
detail
:
msg
.
data
}));
break
;
break
;
default
:
default
:
if
(
this
.
#
registered
.
has
(
msg
.
type
))
{
this
.
dispatchEvent
(
new
CustomEvent
(
msg
.
type
,
{
detail
:
msg
.
data
}));
}
else
{
throw
new
Error
(
"
Unknown message type
"
);
throw
new
Error
(
"
Unknown message type
"
);
}
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
warn
(
"
Unhandled message:
"
,
event
.
data
);
console
.
warn
(
"
Unhandled message:
"
,
event
.
data
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment