Skip to content

Commit

Permalink
Add example for how to add custom API routes (comfyanonymous#3597)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDu authored Jul 1, 2024
1 parent 9dd549e commit 1ef66b0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions custom_nodes/example_node.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ class Example:
# Set the web directory, any .js file in that directory will be loaded by the frontend as a frontend extension
# WEB_DIRECTORY = "./somejs"


# Add custom API routes, using router
from aiohttp import web
from server import PromptServer

@PromptServer.instance.routes.get("/hello")
async def get_hello(request):
return web.json_response("hello")


# A dictionary that contains all nodes you want to export with their names
# NOTE: names should be globally unique
NODE_CLASS_MAPPINGS = {
Expand Down

0 comments on commit 1ef66b0

Please sign in to comment.