mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-20 03:10:16 +08:00
I want decor
This commit is contained in:
parent
4b8b12cf59
commit
e6fbc2bedf
@ -85,17 +85,14 @@ NODE_CLASS_MAPPINGS = {
|
|||||||
"Example": Example
|
"Example": Example
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomEndpoint:
|
class PatchRoutes:
|
||||||
routes = None
|
def __init__(self, routes):
|
||||||
def __init__(self):
|
@routes.get("/test")
|
||||||
self.routes = web.RouteTableDef()
|
|
||||||
|
|
||||||
@self.routes.get("/test")
|
|
||||||
async def get(request):
|
async def get(request):
|
||||||
return web.Response(text="Hello World! This a test endpoint in example_node.py")
|
return web.Response(text="Hello World! This a test endpoint in example_node.py")
|
||||||
|
|
||||||
@self.routes.post("/test")
|
@routes.post("/test")
|
||||||
async def post(request):
|
async def post(request):
|
||||||
text_data = request.text()
|
text_data = await request.text()
|
||||||
return web.Response(text=f"Hello World! This a test endpoint in example_node.py\n\nYour request body: {text_data}")
|
return web.Response(text=f"Hello World! This a test endpoint in example_node.py\n\nYour request body: {text_data}")
|
||||||
|
|
||||||
14
server.py
14
server.py
@ -225,11 +225,6 @@ class PromptServer():
|
|||||||
|
|
||||||
return web.Response(status=200)
|
return web.Response(status=200)
|
||||||
|
|
||||||
self.app.add_routes(routes)
|
|
||||||
self.app.add_routes([
|
|
||||||
web.static('/', self.web_root),
|
|
||||||
])
|
|
||||||
|
|
||||||
def load_custom_endpoint(module_path):
|
def load_custom_endpoint(module_path):
|
||||||
module_name = os.path.basename(module_path)
|
module_name = os.path.basename(module_path)
|
||||||
if os.path.isfile(module_path):
|
if os.path.isfile(module_path):
|
||||||
@ -241,10 +236,9 @@ class PromptServer():
|
|||||||
else:
|
else:
|
||||||
module_spec = importlib.util.spec_from_file_location(module_name, os.path.join(module_path, "__init__.py"))
|
module_spec = importlib.util.spec_from_file_location(module_name, os.path.join(module_path, "__init__.py"))
|
||||||
module = importlib.util.module_from_spec(module_spec)
|
module = importlib.util.module_from_spec(module_spec)
|
||||||
sys.modules[module_name] = module
|
|
||||||
module_spec.loader.exec_module(module)
|
module_spec.loader.exec_module(module)
|
||||||
if hasattr(module, "CustomEndpoint") and getattr(module, "CustomEndpoint") is not None:
|
if hasattr(module, "PatchRoutes") and getattr(module, "PatchRoutes") is not None:
|
||||||
self.app.add_routes(module.CustomEndpoint().routes)
|
module.PatchRoutes(routes)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
print(f"Cannot import {module_path} module for custom endpoints:", e)
|
print(f"Cannot import {module_path} module for custom endpoints:", e)
|
||||||
@ -261,6 +255,10 @@ class PromptServer():
|
|||||||
load_custom_endpoint(module_path)
|
load_custom_endpoint(module_path)
|
||||||
|
|
||||||
load_custom_endpoints()
|
load_custom_endpoints()
|
||||||
|
self.app.add_routes(routes)
|
||||||
|
self.app.add_routes([
|
||||||
|
web.static('/', self.web_root),
|
||||||
|
])
|
||||||
|
|
||||||
def get_queue_info(self):
|
def get_queue_info(self):
|
||||||
prompt_info = {}
|
prompt_info = {}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user