Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

Add example for how to add custom API routes (#3597)

Bob Du1ef66b095586
diff --git a/custom_nodes/example_node.py.example b/custom_nodes/example_node.py.example
index 57c9cbedf..72ca3688c 100644
--- a/custom_nodes/example_node.py.example
+++ b/custom_nodes/example_node.py.example
@@ -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
+
+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 = {