Routes
Routes
The server defines a series of get
and post
methods
which can be found by searching for @routes
in server.py
. When you submit a workflow
in the web client, it is posted to /prompt
which validates the prompt and adds it to an execution queue,
returning either a prompt_id
and number
(the position in the queue), or error
and node_errors
if validation fails.
The prompt queue is defined in execution.py
, which also defines the PromptExecutor
class.
Built in routes
server.py
defines the following routes:
path | get/post | purpose |
---|---|---|
/ | get | load the comfy webpage |
/embeddings | get | retrieve a list of the names of embeddings available |
/extensions | get | retrieve a list of the extensions registering a WEB_DIRECTORY |
/upload/image | post | upload an image |
/upload/mask | post | upload a mask |
/view | get | view an image. Lots of options, see @routes.get("/view") in server.py |
/view_metadata / | get | retrieve metadata for a model |
/system_stats | get | retrieve information about the system (python version, devices, vram etc) |
/prompt | get | retrieve current status |
/prompt | post | submit a prompt to the queue |
/object_info | get | retrieve details of all node types |
/object_info/{node_class} | get | retrieve details of one node type |
/history | get | retrieve the queue history |
/history/{prompt_id} | get | retrieve the queue history for a specific prompt |
/history | post | clear history or delete history item |
/queue | get | retrieve the state of the queue |
/interrupt | post | stop the current workflow |
/free | post | free memory by unloading specified models |
Custom routes
If you want to send a message from the client to the server during execution, you will need to add a custom route to the server. For anything complicated, you will need to dive into the aiohttp framework docs, but most cases can be handled as follows:
my_function
within a class.
The @routes.post
decorator does a lot of work! Instead, define the function as above
and then call a classmethod.@routes.get
if you aren’t changing anything.The client can use this new route by sending a FormData
object with code something like this,
which would result in the_data
, in the above code, containing message
and node_id
keys: